Created
May 29, 2013 05:26
-
-
Save first-developer/5668157 to your computer and use it in GitHub Desktop.
A CodePen by first-developer. Compute window size on resizing - Code use to compute window size when the browser is resizing
This file contains hidden or 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
| <div class="m"></div> |
This file contains hidden or 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 windowResize = function(fun){ | |
| var oldresize = window.onresize; | |
| window.onresize = function(e) { | |
| if (typeof oldresize == 'function') oldresize(e); | |
| fun(e); | |
| } | |
| }; | |
| var res = function (e) { | |
| console.log([e.srcElement.outerWidth, e.srcElement.outerHeight]); | |
| var h = $(".m").outerWidth(); | |
| console.log("Div width ", h); | |
| }; | |
| // jQuery version | |
| /*$(window).on("resize", function(e) { | |
| console.log($(e.target).width()); | |
| });*/ | |
| windowResize(res); | |
This file contains hidden or 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
| .m { | |
| display: block; | |
| width: 100%; | |
| height:20px; | |
| background-color: #000; | |
| box-sizing: border-box; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment