Last active
December 24, 2015 00:29
-
-
Save m9dfukc/6716703 to your computer and use it in GitHub Desktop.
This is a quick and dirty skrollr.js addon which patches the lag of css transforms for svg elements. It adds the ability to use the svg "transform" attribute inside your skrollr style declarations.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* skrollr svg patch | |
* @m9dfukc | |
* Free to use under terms of MIT license | |
* | |
* Add this file after your skrollr.js script. | |
* Example usage: | |
* <div data-0="svg-transform: translate(0 0);" data-1000="svg-transform: translate(200 0);">...</div> | |
*/ | |
(function(document, skrollr) { | |
'use strict'; | |
var _setStyle = skrollr.setStyle; | |
//Monkeypatch the setStyle function. | |
skrollr.setStyle = function(el, prop, val) { | |
if (prop === "svg-transform") { | |
el.setAttribute('transform', val); | |
} else { | |
_setStyle.apply(this, arguments); | |
} | |
}; | |
}(document, window.skrollr)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment