Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
determine proper transform mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiefu committed Sep 18, 2014
1 parent 85a9119 commit 723ed17
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions core-scroll-header-panel.html
Expand Up @@ -76,6 +76,7 @@

</template>
<script>
(function() {

Polymer('core-scroll-header-panel', {

Expand Down Expand Up @@ -291,8 +292,8 @@
},

translateY: function(s, y) {
s.transform = s.webkitTransform = y == null ? '' :
'translate3d(0, ' + y + 'px, 0)';
var t = y == null ? '' : 'translate3d(0, ' + y + 'px, 0)';
setTransform(s, t);
},

scroll: function(event) {
Expand All @@ -311,7 +312,7 @@
}

if (!event || !this.fixed && y !== this.y) {
requestAnimationFrame(this.transformHeader.bind(this, y));
this.transformHeader(y);
}

this.prevScrollTop = Math.max(sTop, 0);
Expand All @@ -323,6 +324,19 @@
}

});

//determine proper transform mechanizm
if (document.documentElement.style.transform !== undefined) {
var setTransform = function(style, string) {
style.transform = string;
}
} else {
var setTransform = function(style, string) {
style.webkitTransform = string;
}
}

})();

</script>
</polymer-element>

0 comments on commit 723ed17

Please sign in to comment.