-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
166 lines (113 loc) · 4.5 KB
/
README
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
D@M Small Slider Version 0.10
=============================
Author
------
David J. Kleszyk, 2014
What is this?
-------------
D@M Small Slider (DSS) is a lightweight, self-contained javascript
package designed to create a semantic slider that can be easily
styled and themed with external css. The goal of DSS is to fufill
the statement "when less is more than enough".
Changes since last release
--------------------------
* Captions no longer animate. Captions will toggle between visible
or hidden during transitions.
* 'delta-t' and 'n-steps' removed as options.
* 'duration' added as new option to control animation length.
* 'tween' added as new option to allow for custom easing functions.
* Default easing function is now SineInOut.
* Uses modular arithmetic for TRDL directions instead of conditions.
* UglifyJS used for minification. Minified file is now 720 bytes
smaller.
* Animations now use requestAnimationFrame instead of setTimeout.
* Restructured code into module system. Increased usage of closures
to leak fewer variables.
Usage
-----
Using DSS is easy. If you want to add in a slider with the default
values, first add the css link in the head of your document.
<link rel="stylesheet" href="dss.css" type="text/css" media="screen" />
Next, in the body of your document, make sure you have a definintion
list set up with the slides you want to use in your slider.
<dl id='your_id_here' class='dss'>
<dt><a href='...' title='' ><img src='...' alt='' /></a></dt>
<dd><p>...</p></dd>
</dl>
Then, at the end of you document, link to the DSS Javascript file and
add the following code.
<script src='dss.js' type='text/javascript' ></script>
<script type='text/javascript' >
//<![CDATA[
var s = dss.slider('your_id_here');
//]]>
</script>
The slider should be created, and start playing with a dwell of five
seconds per slide.
Advanced usage
--------------
Various methods are available for use if you want to tie in DSS
with other javascript operations. These methods are
start
: Starts the slider change timer.
stop
: Stops the slide change timer.
restart
: Restarts the slide change timer. _Does not set slide back
to start value_
slide(direction, ftl-override = null)
: Causes a transition in the direction specified (options
being 'top', 'right', 'bottom', 'left', and 'random'). If
the ftl-override is set, the slideshow will be advanced that
many slides (ftl-override should be an integer).
dir()
: Gets the default forward transition direction.
ndir()
: Gets the default reverse transition direction.
To set various options for the DSS slider, you can pass an options
object as the second argument to the slider. Available options are
dwell
: Time between slide changes in milliseconds. Default 5000.
ftl
: First-to-last. If false, slides go in reverse order.
Default true.
new-slides
: Dynamically add slides to the slider. Array of objects.
Objects have properties 'content' and 'caption',
which refer respectively to the inner HTML of the slide
and caption. Captions added this way should include a
<p></p> tag. Default empty array.
start
: What slide to start at in the range [1,n]. Default 1.
duration
: The time in milliseconds it takes to transition between
slides. Default 750.
direction
: What direction slides should move in while animating. Can
be left, right, top, bottom, or random. Default right.
autostart
: Whether the animation timer should start when the slider
is created. Default true.
tween
: The easing function to use for transitions. Takes the form of
function(t, b, c, d). Default is SineInOut.
### Example 1
var s = dss.slider('your_id_here',{
'new-slides' : [
{'content' :
"<a href='#' title='' ><img src='image-2.jpg' alt='' /></a>",
'caption' :
'<p>another caption to boot!</p>'},
{'content' :
"<a href='#' title='' ><img src='image-3.jpg' alt='' /></a>",
'caption' :
'<p>Wowee! Three slides!</p>'}
]
});
Creates a slider with two additional slides added. The added slides
contain images and have captions.
### Example 2
var s = dss.slider('your_id_here',{'autostart':false});
s.start();
Creates a slider that will not start using the 'autostart'
option, then manually starts it with the start command.