mirror of
https://github.com/wassname/template.git
synced 2026-06-27 19:17:15 +08:00
Real fix to mobile slider bug
This commit is contained in:
+3
-7
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user