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