Created
September 18, 2014 13:34
-
-
Save davestevens/65924f8d17508890293e to your computer and use it in GitHub Desktop.
Scroll Issue in Chrome at 110% zoom
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Scroll Test</title> | |
<style> | |
.wrapper { | |
height: 40px; | |
width: 400px; | |
overflow: auto; | |
} | |
.content { | |
height: 40px; | |
width: 800px; | |
background: repeating-linear-gradient( | |
45deg, | |
#606dbc, | |
#606dbc 10px, | |
#465298 10px, | |
#465298 20px | |
); | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="wrapper" id="js-top-scroll"> | |
<div class="content"></div> | |
</div> | |
<div class="wrapper" id="js-bottom-scroll"> | |
<div class="content"></div> | |
</div> | |
</div> | |
<script src="scroll.js"></script> | |
</body> | |
</html> |
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
class ScrollHandler | |
constructor: (options) -> | |
@top = options.top | |
@bottom = options.bottom | |
bind_events: -> | |
@_bind_top() | |
@_bind_bottom() | |
_bind_top: -> | |
@top.addEventListener("scroll", (event) => | |
@bottom.scrollLeft = event.target.scrollLeft | |
) | |
_bind_bottom: -> | |
@bottom.addEventListener("scroll", (event) => | |
@top.scrollLeft = event.target.scrollLeft | |
) | |
scroll_handler = new ScrollHandler | |
top: document.getElementById("js-top-scroll") | |
bottom: document.getElementById("js-bottom-scroll") | |
scroll_handler.bind_events() |
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
// Generated by CoffeeScript 1.6.2 | |
var ScrollHandler, scroll_handler; | |
ScrollHandler = (function() { | |
function ScrollHandler(options) { | |
this.top = options.top; | |
this.bottom = options.bottom; | |
} | |
ScrollHandler.prototype.bind_events = function() { | |
this._bind_top(); | |
return this._bind_bottom(); | |
}; | |
ScrollHandler.prototype._bind_top = function() { | |
var _this = this; | |
return this.top.addEventListener("scroll", function(event) { | |
return _this.bottom.scrollLeft = event.target.scrollLeft; | |
}); | |
}; | |
ScrollHandler.prototype._bind_bottom = function() { | |
var _this = this; | |
return this.bottom.addEventListener("scroll", function(event) { | |
return _this.top.scrollLeft = event.target.scrollLeft; | |
}); | |
}; | |
return ScrollHandler; | |
})(); | |
scroll_handler = new ScrollHandler({ | |
top: document.getElementById("js-top-scroll"), | |
bottom: document.getElementById("js-bottom-scroll") | |
}); | |
scroll_handler.bind_events(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment