Skip to content

Instantly share code, notes, and snippets.

@m9dfukc
Last active December 24, 2015 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m9dfukc/6716703 to your computer and use it in GitHub Desktop.
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.
/*
* 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