Skip to content

Commit 25c01eb

Browse files
author
Markus Falk
committed
[Task] add custom events
1 parent 5026323 commit 25c01eb

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ Usage
3535
</div>
3636
```
3737

38+
Events
39+
------
40+
41+
```javascript
42+
'tabs.opened' // passes next tab navigational element and content
43+
'tabs.animated' // passes .animated-tabs
44+
```
45+
3846
Installation
3947
------------
4048

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tabs",
33
"main": "tabs.js",
4-
"version": "1.0.0",
4+
"version": "1.1.0",
55
"homepage": "https://github.com/markusfalk/tabs",
66
"authors": [
77
"Markus Falk <mail@markus-falk.com>"

tabs.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ define(['jquery'], function() {
5959
Tabs.start_animation();
6060
// });
6161

62+
// events
63+
this.$tab_element.each(function() {
64+
$(this).trigger('tabs.initialized');
65+
});
66+
6267
},
6368
bindEvents: function() {
6469

@@ -181,6 +186,9 @@ define(['jquery'], function() {
181186
// Inhalte animieren/einblenden
182187
Tabs.animate_content($target_tab);
183188

189+
// events
190+
$target_tab.trigger('tabs.opened', [$target_tab_nav, $target_tab]);
191+
184192
});
185193

186194
},
@@ -189,14 +197,21 @@ define(['jquery'], function() {
189197
// initialen aufruf durch .animated-tabs verhindern
190198
if (Tabs.skip_anim > 0) {
191199
Tabs.$animatedTabs.each(function() {
192-
Tabs.nextTab($(this));
200+
var that = $(this);
201+
202+
Tabs.nextTab(that);
203+
204+
that.trigger('tabs.animated', that);
205+
193206
});
194207
}
195208

196209
// timeout erstellen und skip erhöhen damit if ausgeführt wird
197210
Tabs.animation = setTimeout(Tabs.start_animation, Tabs.autoplay_speed);
198211
Tabs.skip_anim = Tabs.skip_anim + 1;
199212

213+
214+
200215
},
201216
stop_animation: function() {
202217
clearTimeout(Tabs.animation);

0 commit comments

Comments
 (0)