Last active
October 5, 2017 00:05
-
-
Save steveosoule/4206e32a453f4040ebb993e2b302d25d to your computer and use it in GitHub Desktop.
Sync CSS & JS Breakpoint Values
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
RESS = {}; | |
RESS.resize = function() { | |
var a; | |
return function() { | |
clearTimeout(a); | |
a = setTimeout(function() { | |
a = null; | |
RESS.storeSizes(); | |
}, 250); | |
}; | |
}; | |
RESS.writeCookie = function(a, b) { | |
document.cookie = a + "=" + b + "; path=/"; | |
}; | |
RESS.storeSizes = function() { | |
RESS.writeCookie("RESS_width", window.innerWidth); | |
}; | |
RESS.storeSizes(); | |
if (window.getComputedStyle) { | |
window.addEventListener("resize", RESS.resize()); | |
var screenWidth = window.getComputedStyle(document.body, ":after").getPropertyValue("content").replace(/"/g, ''); | |
}; |
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
var breakpoint; | |
var update_breakpoint = function(){ | |
breakpoint = getComputedStyle(document.body, '::after').getPropertyValue('content').replace(/"/g, ''); | |
}; | |
window.addEventListener('resize', update_breakpoint); | |
update_breakpoint(); |
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
body:after { | |
content: 'nano'; | |
display: none; | |
} | |
@media screen and (min-width: 480px) { | |
body:after { | |
content: 'x-small'; | |
} | |
} | |
@media screen and (min-width: 640px) { | |
body:after { | |
content: 'small'; | |
} | |
} | |
@media screen and (min-width: 768px) { | |
body:after { | |
content: 'medium'; | |
} | |
} | |
@media screen and (min-width: 960px) { | |
body:after { | |
content: 'large'; | |
} | |
} | |
@media screen and (min-width: 1170px) { | |
body:after { | |
content: 'x-large'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment