From aed8012d554ca6749f82cdb1179b3e9b3a502173 Mon Sep 17 00:00:00 2001 From: Marc Bachmann Date: Mon, 11 Mar 2019 08:24:13 +0100 Subject: [PATCH 1/5] chore: Upgrade to droneci v1 --- .drone.yml | 69 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/.drone.yml b/.drone.yml index fb31995..40866ce 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,28 +1,43 @@ +--- +kind: pipeline +name: default + clone: - git: - image: plugins/git - depth: 50 - tags: true - -pipeline: - npm-install: - group: install - image: livingdocs/editor-base:8.2 - commands: ["npm install"] - - eslint: - group: install - image: marcbachmann/eslint:4.19.1 - secrets: [gh_token] - - test: - group: test - image: livingdocs/editor-base:8.2 - commands: ["npm run test:ci -s"] - - release: - group: publish - image: marcbachmann/semantic-release:15.1.3 - secrets: [gh_token, npm_token] - when: - event: push + depth: 50 + +steps: +- name: eslint + image: marcbachmann/eslint:4.19.1 + environment: + GH_TOKEN: + from_secret: GH_TOKEN + +- name: npm-install + image: livingdocs/editor-base:8.2 + commands: ["npm install"] + +- name: test + image: livingdocs/editor-base:8.2 + commands: ["npm run test:ci -s"] + +- name: set-build-info + image: node:10 + commands: ["npx set-ci"] + +- name: pre-release + image: livingdocs/editor-base:8.2 + commands: ["git fetch --tags"] + +- name: release + image: marcbachmann/semantic-release:15.1.3 + environment: + GH_TOKEN: + from_secret: GH_TOKEN + NPM_TOKEN: + from_secret: NPM_TOKEN + +--- +kind: signature +hmac: 9ad6f76e9c3ac7e84b8eed453efffd7068c2c3511a36661062ce77795af9ebc5 + +... From dfdca4d584c4d0021e30c19ea75dfc7afcf318ab Mon Sep 17 00:00:00 2001 From: Marc Bachmann Date: Mon, 11 Mar 2019 08:33:29 +0100 Subject: [PATCH 2/5] chore: Disable pull request builds as we do not want two builds for every commit --- .drone.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 40866ce..f3b6df5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -36,8 +36,10 @@ steps: NPM_TOKEN: from_secret: NPM_TOKEN +trigger: + event: [push] --- kind: signature -hmac: 9ad6f76e9c3ac7e84b8eed453efffd7068c2c3511a36661062ce77795af9ebc5 +hmac: 2c74a33a5080dae6dd718539c2a3dbf4662609791c5a8d6ba5c7001a9918226b ... From c0d9d7367e71ae66dcb0c4e705d598867a3d33c5 Mon Sep 17 00:00:00 2001 From: Marc Bachmann Date: Sat, 16 Mar 2019 14:22:29 +0100 Subject: [PATCH 3/5] chore: Simplify semantic-release config --- .drone.yml | 12 ++---------- package.json | 3 +++ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.drone.yml b/.drone.yml index f3b6df5..457dffc 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,16 +20,8 @@ steps: image: livingdocs/editor-base:8.2 commands: ["npm run test:ci -s"] -- name: set-build-info - image: node:10 - commands: ["npx set-ci"] - -- name: pre-release - image: livingdocs/editor-base:8.2 - commands: ["git fetch --tags"] - - name: release - image: marcbachmann/semantic-release:15.1.3 + image: livingdocs/semantic-release:v1.0.0 environment: GH_TOKEN: from_secret: GH_TOKEN @@ -40,6 +32,6 @@ trigger: event: [push] --- kind: signature -hmac: 2c74a33a5080dae6dd718539c2a3dbf4662609791c5a8d6ba5c7001a9918226b +hmac: f4880f26443a82eb8fb348304ec841357b27765613d36a20e1841a212c0a55aa ... diff --git a/package.json b/package.json index 4d4522b..70a22c9 100644 --- a/package.json +++ b/package.json @@ -55,5 +55,8 @@ }, "engines": { "node": ">=6" + }, + "release": { + "extends": "@livingdocs/semantic-release-presets/npm-github" } } From 14de2c32d041be24088ccab10b384d89c5d3331c Mon Sep 17 00:00:00 2001 From: Gabriel Date: Tue, 22 Dec 2020 21:41:13 +0100 Subject: [PATCH 4/5] fix(touch-events): support touch events --- examples/fit-to-area.html | 4 +-- examples/index.html | 4 +-- src/events.js | 53 +++++++++++++++++++++++---------------- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/examples/fit-to-area.html b/examples/fit-to-area.html index e4d7396..1f0620e 100644 --- a/examples/fit-to-area.html +++ b/examples/fit-to-area.html @@ -56,12 +56,12 @@ minRatio: 1 / 1.5 }); - $('.icon-zoom-in').on('click', function(event) { + $('.icon-zoom-in').on('click touchstart', function(event) { crop.zoomIn(); event.stopPropagation(); }); - $('.icon-zoom-out').on('click', function(event) { + $('.icon-zoom-out').on('click touchstart', function(event) { crop.zoomOut(); event.stopPropagation(); }); diff --git a/examples/index.html b/examples/index.html index ffa155b..1599682 100644 --- a/examples/index.html +++ b/examples/index.html @@ -65,12 +65,12 @@ height: 500 }) - $('.icon-zoom-in').on('click', function(event) { + $('.icon-zoom-in').on('click touchstart', function(event) { crop.zoomIn(); event.stopPropagation(); }); - $('.icon-zoom-out').on('click', function(event) { + $('.icon-zoom-out').on('click touchstart', function(event) { crop.zoomOut(); event.stopPropagation(); }); diff --git a/src/events.js b/src/events.js index 6029eee..413976e 100644 --- a/src/events.js +++ b/src/events.js @@ -1,5 +1,15 @@ const $ = require('jquery') +const getPageCoordinates = function (event) { + if (event.type.includes('touch')) { + return { + pageX: event.originalEvent.changedTouches[0].pageX, + pageY: event.originalEvent.changedTouches[0].pageY + } + } + return {pageX: event.pageX, pageY: event.pageY} +} + module.exports = class Events { constructor ({parent, view, horizontal, vertical, actions}) { this.parent = parent @@ -22,20 +32,22 @@ module.exports = class Events { pan () { const $doc = $(document) - this.view.on('mousedown.srcissors', (e1) => { + this.view.on('mousedown.srcissors touchstart.srcissors', (e1) => { const panData = { startX: this.parent.preview.x, startY: this.parent.preview.y } e1.preventDefault() - $doc.on('mousemove.srcissors-pan', (e2) => { - panData.dx = e2.pageX - e1.pageX - panData.dy = e2.pageY - e1.pageY + $doc.on('mousemove.srcissors-pan touchmove.srcissors-pan', (e2) => { + const {pageX, pageY} = getPageCoordinates(e2) + const {pageX: prevPageX, pageY: prevPageY} = getPageCoordinates(e1) + panData.dx = pageX - prevPageX + panData.dy = pageY - prevPageY this.parent.onPan(panData) - }).on('mouseup.srcissors-pan', () => { - $doc.off('mouseup.srcissors-pan') - $doc.off('mousemove.srcissors-pan') + }).on('mouseup.srcissors-pan touchend.srcissors-pan', () => { + $doc.off('mouseup.srcissors-pan touchend.srcissors-pan') + $doc.off('mousemove.srcissors-pan touchmove.srcissors-pan') // only trigger panEnd if pan has been called if (panData.dx != null) this.parent.onPanEnd() @@ -46,10 +58,10 @@ module.exports = class Events { doubleClick () { let lastClick - this.view.on('mousedown.srcissors', event => { + this.view.on('mousedown.srcissors touchstart.srcissors', event => { const now = new Date().getTime() if (lastClick && (lastClick > (now - this.doubleClickThreshold))) { - this.parent.onDoubleClick({pageX: event.pageX, pageY: event.pageY}) + this.parent.onDoubleClick(getPageCoordinates(event)) } lastClick = now }) @@ -73,7 +85,7 @@ module.exports = class Events { positions.forEach(position => { const $handler = $template.clone() $handler.addClass(`resize-handler-${position}`) - $handler.on('mousedown.srcissors', this.getResizeMouseDown(position)) + $handler.on('mousedown.srcissors touchstart.srcissors', this.getResizeMouseDown(position)) this.view.append($handler) }) @@ -83,30 +95,29 @@ module.exports = class Events { const $doc = $(document) return (event) => { - let lastX = event.pageX - let lastY = event.pageY - + let {pageX: lastX, pageY: lastY} = getPageCoordinates(event) event.stopPropagation() - $doc.on('mousemove.srcissors-resize', e2 => { + $doc.on('mousemove.srcissors-resize touchmove.srcissors-resize', e2 => { let dx, dy + const {pageX, pageY} = getPageCoordinates(e2) switch (position) { case 'top': case 'bottom': - dy = e2.pageY - lastY + dy = pageY - lastY if (position === 'top') { dy = -dy } - lastY = e2.pageY + lastY = pageY break case 'left': case 'right': - dx = e2.pageX - lastX + dx = pageX - lastX if (position === 'left') { dx = -dx } - lastX = e2.pageX + lastX = pageX break } this.parent.onResize({position, dx, dy}) - }).on('mouseup.srcissors-resize', () => { - $doc.off('mouseup.srcissors-resize') - $doc.off('mousemove.srcissors-resize') + }).on('mouseup.srcissors-resize touchend.srcissors-resize', () => { + $doc.off('mouseup.srcissors-resize touchmove.srcissors-resize') + $doc.off('mousemove.srcissors-resize touchend.srcissors-resize') // only trigger panEnd if pan has been called this.parent.onResizeEnd({position}) From dfadd3284aeff2ab0d9b9dc6b844b0a0406b7796 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Wed, 6 Jan 2021 16:38:34 +0100 Subject: [PATCH 5/5] chore(zoom): implement feedback --- examples/fit-to-area.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/fit-to-area.html b/examples/fit-to-area.html index 1f0620e..6611bf5 100644 --- a/examples/fit-to-area.html +++ b/examples/fit-to-area.html @@ -56,12 +56,12 @@ minRatio: 1 / 1.5 }); - $('.icon-zoom-in').on('click touchstart', function(event) { + $('.icon-zoom-in').on('mouseup touchstart', function(event) { crop.zoomIn(); event.stopPropagation(); }); - $('.icon-zoom-out').on('click touchstart', function(event) { + $('.icon-zoom-out').on('mouseup touchstart', function(event) { crop.zoomOut(); event.stopPropagation(); });