Skip to content

Commit 6f5c82a

Browse files
committed
Updated bower.json
1 parent d04624e commit 6f5c82a

File tree

3 files changed

+54
-26
lines changed

3 files changed

+54
-26
lines changed

bower.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "md-scroll",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"authors": [
55
"S. Francis"
66
],
@@ -41,7 +41,8 @@
4141
],
4242
"dependencies": {
4343
"polymer": "Polymer/polymer#^1.0.0",
44-
"elliptical-polymer-behaviors": "~1.1.0"
44+
"elliptical-polymer-behaviors": "~1.1.0",
45+
"elliptical-mutation-summary": "~1.0.2"
4546
},
4647
"devDependencies": {
4748
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",

md-scroll.html

+50-23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<link rel="import" href="../polymer/polymer.html">
2+
<link rel="import" href="../elliptical-polymer-behaviors/component-behavior.html">
3+
<link rel="import" href="../elliptical-mutation-summary/elliptical-mutation-summary.html">
24
<script src="ftscroller.js"></script>
35

46
<dom-module id="md-scroll">
@@ -12,43 +14,68 @@
1214

1315
is: 'md-scroll',
1416

17+
behaviors: [Elliptical.ComponentBehavior],
1518

1619
properties: {
17-
selector:{
18-
type:String,
19-
value:null
20-
},
21-
_scroller:{
22-
type:Object,
23-
value:null
24-
}
20+
selector:{
21+
type:String,
22+
value:'[md-scroll]'
23+
},
24+
_scroller:{
25+
type:Object,
26+
value:null
27+
}
2528
},
2629

2730
ready:function(){
28-
var self=this;
29-
setTimeout(function(){
30-
self._initScroll();
31-
},500);
31+
this._events();
3232
},
3333

3434
detached:function(){
35-
var scroller=this._scroller;
36-
scroller.destroy();
35+
this._destroyScroller();
3736
},
3837

39-
_initScroll:function(){
40-
var selector=(this.selector) ? this.selector : '[md-scroll]';
41-
var container = $(document).find(selector)[0];
42-
if(container){
43-
var scroller = new FTScroller(container, {
44-
scrollbars: false,
45-
scrollingX: false
46-
});
47-
this._scroller=scroller;
38+
_events:function(){
39+
this._event($(document),'OnDocumentMutation',this._onMutation.bind(this));
40+
},
4841

42+
_onMutation:function(event,summary){
43+
var self=this;
44+
var scrollable;
45+
var added=summary.added;
46+
var removed=summary.removed;
47+
if(added && added.length > 0) {
48+
if(this._scroller) return;
49+
added=$(added);
50+
scrollable=added.find(this.selector);
51+
if(scrollable[0]) {
52+
setTimeout(function(){
53+
self._initScroll(scrollable[0]);
54+
},1250);
55+
}
56+
}
57+
if(removed && removed.length){
58+
if(!this._scroller) return;
59+
removed=$(removed);
60+
scrollable=removed.find(this.selector);
61+
if(scrollable[0]) this._destroyScroller();
4962
}
5063
},
5164

65+
_destroyScroller:function(){
66+
var scroller=this._scroller;
67+
if(scroller) scroller.destroy();
68+
},
69+
70+
_initScroll:function(scrollable){
71+
var scroller = new FTScroller(scrollable, {
72+
scrollbars: false,
73+
scrollingX: false
74+
});
75+
76+
this._scroller=scroller;
77+
}
78+
5279
});
5380

5481
</script>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "md-scroll",
33
"description": "md-scroll",
4-
"version": "1.0.3",
4+
"version": "1.0.4",
55
"author": "S. Francis",
66
"license": "MIT",
77
"repository": {

0 commit comments

Comments
 (0)