Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add context-menu property #93

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
5bc2ea7
Add draggableImage property for right clicking and draggin while imag…
Jun 10, 2016
ced4349
Add draggableImage property for right clicking and draggin while imag…
Westbrook Jun 10, 2016
8857ad4
Merge branch 'master' of https://github.com/Westbrook/iron-image
Westbrook Jun 10, 2016
1b4424e
Add `draggableImage` property
Westbrook Jun 10, 2016
cb4e74a
Adds `draggableImage` demo
Westbrook Jun 10, 2016
23bbb9a
Merge branch 'master' of https://github.com/Westbrook/iron-image
Westbrook Aug 22, 2016
355301c
Merge branch 'master' of https://github.com/Westbrook/iron-image
Westbrook Aug 22, 2016
227bb92
Update draggable-image to context-menu
Westbrook Aug 22, 2016
31a04dc
Update draggable-image to context-menu
Westbrook Aug 22, 2016
c65bdb4
Add context-menu property for dragging to save and right clicking
Westbrook Aug 22, 2016
06483ec
Revert "Add context-menu property for dragging to save and right clic…
Westbrook Aug 22, 2016
f7ad6da
Add context-menu property for right clicking and dragging to save
Westbrook Aug 22, 2016
91edc8e
merge
Westbrook Apr 26, 2017
57d116c
merge
Westbrook Apr 26, 2017
9f672f6
TO master
Westbrook Apr 26, 2017
4b040f1
TO master
Westbrook Apr 26, 2017
b86e72c
Add draggableImage property for right clicking and draggin while imag…
Westbrook Jun 10, 2016
0de9d4e
Merge branch 'master' of https://github.com/Westbrook/iron-image
Westbrook Jun 10, 2016
1e37108
Merge branch 'master' of https://github.com/Westbrook/iron-image
Westbrook Apr 26, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
language: node_js
sudo: required
before_script:
- npm install -g bower polylint web-component-tester
- bower install
- polylint
- npm install -g bower polylint web-component-tester
- bower install
- polylint
env:
global:
- secure: JOd5P49LsE77iYvmnXcjrv4UOPBz5iXed34LnK4FB8+hJ79wFan/HuymA8mof1FDnyBYFqV9Zgmeo2BAmFxomtADwLL6fcX34fh5r0JPuM6pv1ovoaE/yNBrt3o7RfhQ9/VkezjGBFkrXF8ciw2e+OHu6aEcAvdqG8O0UqWHVn4=
- secure: HV8pPsLmz3GsoAyAnJosqMPVL/2QA/0G71b9KTrXGvnydRwPfaxPmgklrVs0S8LlS4t1OzJcL1M8p/k2ulWL/OsmG+KVB2LRB51JsrhfDEb+XF9VpXFXv5TSx2Bv9RE4gBlY2YaVnpq5OsL9oQDLmwMvsEcPZPF/nRfnbG6zD6g=
node_js: stable
- secure: >-
JOd5P49LsE77iYvmnXcjrv4UOPBz5iXed34LnK4FB8+hJ79wFan/HuymA8mof1FDnyBYFqV9Zgmeo2BAmFxomtADwLL6fcX34fh5r0JPuM6pv1ovoaE/yNBrt3o7RfhQ9/VkezjGBFkrXF8ciw2e+OHu6aEcAvdqG8O0UqWHVn4=
- secure: >-
HV8pPsLmz3GsoAyAnJosqMPVL/2QA/0G71b9KTrXGvnydRwPfaxPmgklrVs0S8LlS4t1OzJcL1M8p/k2ulWL/OsmG+KVB2LRB51JsrhfDEb+XF9VpXFXv5TSx2Bv9RE4gBlY2YaVnpq5OsL9oQDLmwMvsEcPZPF/nRfnbG6zD6g=
node_js: '6'
addons:
firefox: '46.0'
firefox: latest
apt:
sources:
- google-chrome
- google-chrome
packages:
- google-chrome-stable
sauce_connect: true
- google-chrome-stable
script:
- xvfb-run wct
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct -s 'default'; fi
- xvfb-run wct
- 'if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct -s ''default''; fi'
dist: trusty
20 changes: 19 additions & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<head>

<title>iron-image demo</title>

<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
Expand Down Expand Up @@ -89,6 +89,24 @@ <h3>
</template>
</demo-snippet>

<h3>
<code>sizing="contain|cover"</code> with <code>has-context-menu</code> allows
the image to still be right clicked as well as dragged.
</h3>
<demo-snippet class="centered-demo">
<template>
<style is="custom-style">
#example-sizing-contain {
width: 150px;
height: 150px;
background: #ddd;
}
</style>

<iron-image sizing="contain" has-context-menu id="example-sizing-contain" alt="The Polymer logo." src="./polymer.svg"></iron-image>
</template>
</demo-snippet>

<h3>
Use the <code>--iron-image-width</code> property to set the width of
the image wrapped by the <code>iron-image</code>.
Expand Down
33 changes: 31 additions & 2 deletions iron-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
<iron-image style="width:400px; height:400px;" sizing="cover"
src="http://lorempixel.com/600/400"></iron-image>

Will allow sized image be be right clicked and dragged:

<iron-image style="width:400px; height:400px;" sizing="cover"
has-context-menu src="http://lorempixel.com/600/400"></iron-image>

Will show light-gray background until the image loads:

<iron-image style="width:400px; height:400px; background-color: lightgray;"
Expand Down Expand Up @@ -98,6 +103,16 @@
display: none;
}

:host([has-context-menu][sizing]) #img {
display: block;
height: 100%;
left: 0;
opacity: 0;
position: relative;
top: 0;
width: 100%;
}

#placeholder {
@apply(--layout-fit);

Expand All @@ -118,7 +133,7 @@
hidden$="[[_computeImgDivHidden(sizing)]]"
aria-hidden$="[[_computeImgDivARIAHidden(alt)]]"
aria-label$="[[_computeImgDivARIALabel(alt, src)]]"></div>
<img id="img" alt$="[[alt]]" hidden$="[[_computeImgHidden(sizing)]]">
<img id="img" alt$="[[alt]]" hidden$="[[_computeImgHidden(sizing, hasContextMenu)]]">
<div id="placeholder"
hidden$="[[_computePlaceholderHidden(preload, fade, loading, loaded)]]"
class$="[[_computePlaceholderClassName(preload, fade, loading, loaded)]]"></div>
Expand Down Expand Up @@ -260,6 +275,20 @@
type: Number,
value: null
},

/**
* Can the <img/> be right clicked or dragged when sizing is set.
*
* @attribute hasContextMenu
* @type boolean
* @default false
*/

hasContextMenu: {
type: Boolean,
value: false,
reflectToAttribute: true
},
},

observers: [
Expand Down Expand Up @@ -344,7 +373,7 @@
},

_computeImgHidden: function() {
return !!this.sizing;
return !!this.sizing && !this.hasContextMenu;
},

_widthChanged: function() {
Expand Down