From 79e58884de33c04482765acf896bc8103030a426 Mon Sep 17 00:00:00 2001 From: "Pat O'Neill" Date: Wed, 19 Aug 2015 13:54:47 -0400 Subject: [PATCH] @misternoneill fixed vertical slider issues. closes #2469 --- CHANGELOG.md | 1 + src/js/slider/slider.js | 25 ++++--------------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b76d7397b..4a24449ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -98,6 +98,7 @@ CHANGELOG * @gkatsev fixed text track errors on dispose and in cross-browser testing ([view](https://github.com/videojs/video.js/pull/2466)) * @mmcc added type=button to button components ([view](https://github.com/videojs/video.js/pull/2471)) * @mmcc Fixed IE by using setAttribute to set 'type' property ([view](https://github.com/videojs/video.js/pull/2487)) +* @misternoneill fixed vertical slider issues ([view](https://github.com/videojs/video.js/pull/2469)) -------------------- diff --git a/src/js/slider/slider.js b/src/js/slider/slider.js index 304d62b78..bc7d4dd9e 100644 --- a/src/js/slider/slider.js +++ b/src/js/slider/slider.js @@ -19,12 +19,11 @@ class Slider extends Component { constructor(player, options) { super(player, options); - // Set property names to bar and handle to match with the child Slider class is looking for - this.bar = this.getChild(this.options_['barName']); - this.handle = this.getChild(this.options_['handleName']); + // Set property names to bar to match with the child Slider class is looking for + this.bar = this.getChild(this.options_.barName); // Set a horizontal or vertical class on the slider depending on the slider type - this.vertical(!!this.options_['vertical']); + this.vertical(!!this.options_.vertical); this.on('mousedown', this.handleMouseDown); this.on('touchstart', this.handleMouseDown); @@ -150,9 +149,8 @@ class Slider extends Component { let box = Dom.findElPosition(el); let boxW = el.offsetWidth; let boxH = el.offsetHeight; - let handle = this.handle; - if (this.options_['vertical']) { + if (this.vertical()) { let boxY = box.top; let pageY; @@ -162,13 +160,6 @@ class Slider extends Component { pageY = event.pageY; } - if (handle) { - var handleH = handle.el().offsetHeight; - // Adjusted X and Width, so handle doesn't go outside the bar - boxY = boxY + (handleH / 2); - boxH = boxH - handleH; - } - // Percent that the click is through the adjusted area return Math.max(0, Math.min(1, ((boxY - pageY) + boxH) / boxH)); @@ -182,14 +173,6 @@ class Slider extends Component { pageX = event.pageX; } - if (handle) { - var handleW = handle.el().offsetWidth; - - // Adjusted X and Width, so handle doesn't go outside the bar - boxX = boxX + (handleW / 2); - boxW = boxW - handleW; - } - // Percent that the click is through the adjusted area return Math.max(0, Math.min(1, (pageX - boxX) / boxW)); }