fix: allow right-click to save image (#962)

fixes #961
This commit is contained in:
Nolan Lawson 2019-02-10 13:03:24 -08:00 committed by GitHub
parent 37a95c04ab
commit fdcaa864af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 32 deletions

View File

@ -11,8 +11,8 @@
<li class="media-scroll-item"> <li class="media-scroll-item">
<div class="media-scroll-item-inner"> <div class="media-scroll-item-inner">
<div class="media-scroll-item-inner-inner"> <div class="media-scroll-item-inner-inner">
{#if canPinchZoom} {#if canPinchZoom && pinchZoomMode}
<PinchZoomable className='media-pinch-zoom' disabled={!pinchZoomMode} > <PinchZoomable className='media-pinch-zoom' >
<MediaInDialog {media} /> <MediaInDialog {media} />
</PinchZoomable> </PinchZoomable>
{:else} {:else}

View File

@ -1,4 +1,4 @@
<div class="pinch-zoom {disabled ? 'pinch-zoom-disabled' : ''} {className ? className : ''}" > <div class="pinch-zoom {className ? className : ''}" >
<pinch-zoom class="pinch-zoom-inner" ref:node> <pinch-zoom class="pinch-zoom-inner" ref:node>
<slot></slot> <slot></slot>
</pinch-zoom> </pinch-zoom>
@ -8,7 +8,6 @@
label="Zoom out" label="Zoom out"
href="#fa-search-minus" href="#fa-search-minus"
on:click="zoomOut()" on:click="zoomOut()"
ariaHidden={disabled}
/> />
<IconButton <IconButton
className="pinch-zoom-button pinch-zoom-button-zoom-in" className="pinch-zoom-button pinch-zoom-button-zoom-in"
@ -16,16 +15,12 @@
label="Zoom in" label="Zoom in"
href="#fa-search-plus" href="#fa-search-plus"
on:click="zoomIn()" on:click="zoomIn()"
ariaHidden={disabled}
/> />
</div> </div>
<style> <style>
.pinch-zoom { .pinch-zoom {
position: relative; position: relative;
} }
.pinch-zoom-disabled {
pointer-events: none;
}
.pinch-zoom-inner { .pinch-zoom-inner {
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -62,34 +57,18 @@
padding-right: 5px; padding-right: 5px;
} }
} }
:global(.pinch-zoom-disabled .pinch-zoom-button) {
visibility: hidden;
}
</style> </style>
<script> <script>
import IconButton from '../../IconButton.html' import IconButton from '../../IconButton.html'
import 'pinch-zoom-element/dist/pinch-zoom.js' import 'pinch-zoom-element/dist/pinch-zoom.js'
import { observe } from 'svelte-extras'
const ZOOM_INCREMENT = 0.1 const ZOOM_INCREMENT = 0.1
export default { export default {
oncreate () {
this.observe('disabled', disabled => {
if (disabled) {
this.resetZoom()
}
}, { init: false })
},
data: () => ({
disabled: false
}),
components: { components: {
IconButton IconButton
}, },
methods: { methods: {
observe,
zoomIn () { zoomIn () {
this.zoomBy(ZOOM_INCREMENT) this.zoomBy(ZOOM_INCREMENT)
}, },
@ -103,14 +82,6 @@
originX: '50%', originX: '50%',
originY: '50%' originY: '50%'
}) })
},
resetZoom () {
let { node } = this.refs
node.setTransform({
scale: 1,
x: 0,
y: 0
})
} }
} }
} }