jQuery ScrollView: Default Functionality

jqxScrollView represents a widget which can be used for viewing content which is wider than the visible area outlined by the device's screen. Specific item can be chosen using drag movements or clicking/tapping on the buttons at the bottom of the jqxScrollView.

A live JavaScript/jQuery example of jqxScrollView, the jQWidgets ScrollView component, with its complete source code below. The jqxScrollView page for jQuery has its introduction and links.

jqxScrollView API used in this demo

Source code

To run it in your own page, load jqx.base.css, a theme and the library files below from npm (npm install jqwidgets-scripts) or the jsDelivr CDN, then add the markup and the script. jQuery is not required: jqxcore.js provides $. Getting started with jqxScrollView shows the setup step by step.

The page loads jqx.base.css, a theme and these library files: jqxcore.js, jqxscrollview.js, jqxbuttons.js.

It also loads helper scripts of this demo site, which are not part of the library: demos.js (getWidth() and other layout helpers).

script.js

$(function () {
    $('#photoGallery').jqxScrollView({ width: 600, height: 450, buttonsOffset: [0, 0]});
    $('#StartBtn').jqxButton({ theme: theme });
    $('#StopBtn').jqxButton({ theme: theme });
    $('#StartBtn').click(function () {
        $('#photoGallery').jqxScrollView({ slideShow: true });
    });
    $('#StopBtn').click(function () {
        $('#photoGallery').jqxScrollView({ slideShow: false });
    });
});

body.html

<div id="photoGallery">
    <div><div class="photo" style="background-image: url(../../images/imageNature1.jpg)"></div></div>
    <div><div class="photo" style="background-image: url(../../images/imageNature2.jpg)"></div></div>
    <div><div class="photo" style="background-image: url(../../images/imageNature3.jpg)"></div></div>
    <div><div class="photo" style="background-image: url(../../images/imageNature4.jpg)"></div></div>
    <div><div class="photo" style="background-image: url(../../images/imageNature5.jpg)"></div></div>
</div>
<div style="margin-top: 20px;">
    <br>
    <div>
        <input type="button" value="Start Slideshow" id="StartBtn">
        <input type="button" value="Stop Slideshow" id="StopBtn">
    </div>
</div>

Learn more