Real fix to mobile slider bug

This commit is contained in:
Shan Carter
2017-10-23 11:39:13 -07:00
parent f046442753
commit 4089ccf98f
+3 -7
View File
@@ -2,8 +2,7 @@ import { Template } from '../mixins/template';
import { scaleLinear } from 'd3-scale';
import { range } from 'd3-array';
import { drag } from 'd3-drag';
import { select } from 'd3-selection';
import {event as currentEvent } from 'd3-selection';
import { select, event as currentEvent } from 'd3-selection';
const T = Template('d-slider', `
<style>
@@ -148,7 +147,7 @@ export class Slider extends T(HTMLElement) {
this.renderTicks();
this.drag = drag()
.container(this.track)
.container(this.background)
.on("start", () => {
this.mouseEvent = true;
this.background.classList.add("mousedown");
@@ -156,7 +155,6 @@ export class Slider extends T(HTMLElement) {
this.dragUpdate();
})
.on("drag", () => {
console.log(event)
this.dragUpdate();
})
.on("end", () => {
@@ -260,9 +258,7 @@ export class Slider extends T(HTMLElement) {
dragUpdate() {
const bbox = this.background.getBoundingClientRect();
console.log(event, bbox, bbox.left)
const left = bbox.left;
const x = event.pageX - left;
const x = currentEvent.x;
const width = bbox.width;
this.update(this.scale.invert(x / width));
}