Skip to content

drag-scroll


Basic usage

The most common, basic usage of drag-scroll.
Drag the image below to scroll its parent container.

landscape-coast
code

Separate element and container

It's not necessary to make corresponding scrollable container exactly the draggable element's parent.
For the example below, use the grey "touchpad" to scroll the container.

landscape-coast
code

Movement

With option movement, you can define how the dragscroll movement will be.

Lock axis

Dragscroll behavior will only take place on x-axis, y-axis, or both (will not scroll at all).

Lock x-axis.

landscape-coast

Lock y-axis.

landscape-coast
code

Reverse scroll direction

Reverse scroll direction along x-axis, y-axis, or both.

Reverse x-axis.

landscape-coast

Reverse y-axis.

landscape-coast

Reverse both x-axis and y-axis.

landscape-coast
code

Swap controls

Horizontal drag will effect vertical scroll, and vice versa.

landscape-coast
code

Constrained

Dragscroll can only happen when cursor is inside the scrollable container.

landscape-coast
code

Sensitivity

To accurately define dragscroll's sensitivity, scale the ratio of drag_trigger_threshold to scroll_respond_vector.

Normal: For the example below, 1px drag triggers 1px scroll.

landscape-coast
1234567891011121314151617181920

Less sensitive: For the example below, 5px drag triggers 1px scroll.

landscape-coast
1234567891011121314151617181920

More sensitive: For the example below, 1px drag triggers 5px scroll.

landscape-coast
1234567891011121314151617181920

Scaled sensitive: For the example below, 10px drag triggers 10px scroll.

landscape-coast
1234567891011121314151617181920
code

Modify state

Update, disable or destroy an existing dragscroll.

landscape-coast
code

Avoidance

Dragscroll won't take effect on those elements assigned as avoids.

For the example below, order number divs are avoided.

012345678910111213141516171819
code

Example - A dragscrollable sticky table

Drag the table head to scroll table horizontally.
Drag the first column to scroll table vertically.

The sticky capability is carried by stick-element.

row_n
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
age
sex
bmi
children
smoker
region
charges
19female27.90yessouthwest16884.924
18male33.771nosoutheast1725.5523
28male333nosoutheast4449.462
33male22.7050nonorthwest21984.47061
32male28.880nonorthwest3866.8552
31female25.740nosoutheast3756.6216
46female33.441nosoutheast8240.5896
37female27.743nonorthwest7281.5056
37male29.832nonortheast6406.4107
60female25.840nonorthwest28923.13692
25male26.220nonortheast2721.3208
62female26.290yessoutheast27808.7251
23male34.40nosouthwest1826.843
56female39.820nosoutheast11090.7178
27male42.130yessoutheast39611.7577
19male24.61nosouthwest1837.237
52female30.781nonortheast10797.3362
23male23.8450nonortheast2395.17155
56male40.30nosouthwest10602.385
30male35.30yessouthwest36837.467
60female36.0050nonortheast13228.84695
30female32.41nosouthwest4149.736
18male34.10nosoutheast1137.011
34female31.921yesnortheast37701.8768
37male28.0252nonorthwest6203.90175
59female27.723nosoutheast14001.1338
63female23.0850nonortheast14451.83515
55female32.7752nonorthwest12268.63225
23male17.3851nonorthwest2775.19215
31male36.32yessouthwest38711
22male35.60yessouthwest35585.576
18female26.3150nonortheast2198.18985
19female28.65nosouthwest4687.797
63male28.310nonorthwest13770.0979
28male36.41yessouthwest51194.55914
19male20.4250nonorthwest1625.43375
62female32.9653nonorthwest15612.19335
26male20.80nosouthwest2302.3
35male36.671yesnortheast39774.2763
60male39.90yessouthwest48173.361
24female26.60nonortheast3046.062
31female36.632nosoutheast4949.7587
41male21.781nosoutheast6272.4772
37female30.82nosoutheast6313.759
38male37.051nonortheast6079.6715
55male37.30nosouthwest20630.28351
18female38.6652nonortheast3393.35635
28female34.770nonorthwest3556.9223
60female24.530nosoutheast12629.8967
36male35.21yessoutheast38709.176
18female35.6250nonortheast2211.13075
21female33.632nonorthwest3579.8287
48male281yessouthwest23568.272
36male34.430yessoutheast37742.5757
40female28.693nonorthwest8059.6791
58male36.9552yesnorthwest47496.49445
58female31.8252nonortheast13607.36875
18male31.682yessoutheast34303.1672
53female22.881yessoutheast23244.7902
34female37.3352nonorthwest5989.52365
43male27.363nonortheast8606.2174
25male33.664nosoutheast4504.6624
64male24.71nonorthwest30166.61817
28female25.9351nonorthwest4133.64165
20female22.420yesnorthwest14711.7438
19female28.90nosouthwest1743.214
61female39.12nosouthwest14235.072
40male26.3151nonorthwest6389.37785
40female36.190nosoutheast5920.1041
28male23.983yessoutheast17663.1442
27female24.750yessoutheast16577.7795
31male28.55nonortheast6799.458
53female28.13nosouthwest11741.726
58male32.011nosoutheast11946.6259
44male27.42nosouthwest7726.854
57male34.010nonorthwest11356.6609
29female29.591nosoutheast3947.4131
21male35.530nosoutheast1532.4697
22female39.8050nonortheast2755.02095
41female32.9650nonorthwest6571.02435
31male26.8851nonortheast4441.21315
45female38.2850nonortheast7935.29115
22male37.621yessoutheast37165.1638
48female41.234nonorthwest11033.6617
37female34.82yessouthwest39836.519
45male22.8952yesnorthwest21098.55405
57female31.160yesnorthwest43578.9394
56female27.20nosouthwest11073.176
46female27.740nonorthwest8026.6666
55female26.980nonorthwest11082.5772
21female39.490nosoutheast2026.9741
53female24.7951nonorthwest10942.13205
59male29.833yesnortheast30184.9367
35male34.772nonorthwest5729.0053
64female31.32yessouthwest47291.055
28female37.621nosoutheast3766.8838
54female30.83nosouthwest12105.32
55male38.280nosoutheast10226.2842
56male19.950yesnortheast22412.6485
38male19.30yessouthwest15820.699
code