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

Keymapper phase 2 enhancements #243

Merged
merged 88 commits into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
7a6822c
Control toolbar + Keymap guide + Util fn to make custom toolbars
rexagod Feb 22, 2019
ebd4680
Toolbar options
rexagod Mar 1, 2019
f6d76e5
default toolbarType and expose Guides
rexagod Mar 16, 2019
f8f2a50
fix conflicts
rexagod Mar 20, 2019
feea0ff
Update src/edit/tools/DistortableImage.Guides.js
sashadev-sky Apr 13, 2019
59b50a9
Update .gitignore
rexagod Apr 13, 2019
04a9d94
develop on sashadev-sky's review
rexagod Apr 13, 2019
ca69659
delete extra bracket causing error after rebase
sashadev-sky Apr 17, 2019
68f3469
remove intent technique
rexagod Apr 18, 2019
459b90f
Update Gruntfile.js
rexagod Apr 18, 2019
2fac601
force build dist
rexagod Apr 18, 2019
3fe0535
all tests passing
rexagod Apr 21, 2019
c5cd94c
removed guides
rexagod Apr 21, 2019
f94687a
addToolbar -> keymapper
rexagod Apr 21, 2019
e4704ba
Control toolbar + Keymap guide + Util fn to make custom toolbars
rexagod Feb 22, 2019
03d1c39
Update src/edit/tools/DistortableImage.Guides.js
sashadev-sky Apr 13, 2019
a09d638
Update .gitignore
rexagod Apr 13, 2019
5e447c3
develop on sashadev-sky's review
rexagod Apr 13, 2019
0e2d505
Update Gruntfile.js
rexagod Apr 18, 2019
d8121ed
force build dist
rexagod Apr 18, 2019
eeaf606
package-json fixed
sashadev-sky Apr 22, 2019
f3e8c82
add hiding functionality
rexagod Apr 23, 2019
3310794
relocate to ../
rexagod May 1, 2019
5eca600
remove erroneous coverage from build, extend from L.Handler, remove i…
rexagod May 3, 2019
debd94a
merge position and init
rexagod May 4, 2019
9a2f1e1
make similar changes in select.html
rexagod May 4, 2019
f818174
set topright as default position
rexagod May 4, 2019
8246da8
add disable functionality
rexagod May 25, 2019
78b0d8c
modify keymapper ui #258
rexagod May 26, 2019
a38837a
Fix rebase
sashadev-sky Jun 5, 2019
0ade206
fixed rebase 2
sashadev-sky Jun 5, 2019
6d4eef5
Fix rebase 3
sashadev-sky Jun 5, 2019
45ffdee
initiate orb algo UI integration
rexagod Jun 8, 2019
78eb4c7
Revert "initiate orb algo UI integration"
rexagod Jun 8, 2019
837062b
Merge branch 'main' of https://github.com/rexagod/Leaflet.Distortable…
sashadev-sky Jul 15, 2019
6244971
rebase
sashadev-sky Jul 15, 2019
6a0da0b
Make updates on rexagods updates
sashadev-sky Jul 15, 2019
3863415
keymapperinitially collapsed
sashadev-sky Jul 15, 2019
b24e2c6
Keymapper toggle no longer propogates and hides image toolbar
sashadev-sky Jul 15, 2019
636d9f0
finished draft
sashadev-sky Jul 15, 2019
01de5af
add disable and instance check functionality
rexagod Jul 20, 2019
d9a2c1d
remove instance count for DistortableImage.Edit
sashadev-sky Jul 23, 2019
9d873c8
remove .vscode from modified files
sashadev-sky Jul 23, 2019
8fbcd49
Merge branch 'main' into keymapper-phase-2
sashadev-sky Jul 23, 2019
f8837a3
add removeHooks
rexagod Jul 23, 2019
ea37095
Merge branch 'keymapper-phase-2' of github.com:rexagod/Leaflet.Distor…
rexagod Jul 23, 2019
fcc0ec6
merge changes
rexagod Jul 23, 2019
dea5c58
add enable functionality
rexagod Jul 24, 2019
403e4d9
fix so that enable works
sashadev-sky Jul 27, 2019
6611791
rebase
sashadev-sky Jul 30, 2019
c4b6359
Control toolbar + Keymap guide + Util fn to make custom toolbars
rexagod Feb 22, 2019
d2cbb8e
Toolbar options
rexagod Mar 1, 2019
5b3c6f6
default toolbarType and expose Guides
rexagod Mar 16, 2019
d1979d1
develop on sashadev-sky's review
rexagod Apr 13, 2019
c7e8846
force build dist
rexagod Apr 18, 2019
725c6a2
remove erroneous coverage from build, extend from L.Handler, remove i…
rexagod May 3, 2019
228d7c8
Fix rebase 3
sashadev-sky Jun 5, 2019
2783e74
Make updates on rexagods updates
sashadev-sky Jul 15, 2019
79c3277
add disable and instance check functionality
rexagod Jul 20, 2019
0bd1baf
remove instance count for DistortableImage.Edit
sashadev-sky Jul 23, 2019
f4165d0
add removeHooks
rexagod Jul 23, 2019
da95097
fix so that enable works
sashadev-sky Jul 27, 2019
7e5f285
all fixed
sashadev-sky Jul 27, 2019
de25eee
restructure
sashadev-sky Jul 27, 2019
a6f30e4
More refactoring
sashadev-sky Jul 27, 2019
7c3b715
changge from button to a
sashadev-sky Jul 27, 2019
ff6c939
updates
sashadev-sky Jul 27, 2019
9f83462
clean up
sashadev-sky Jul 27, 2019
59b93d7
clean up
sashadev-sky Jul 27, 2019
027fd01
fix broken package-lock
sashadev-sky Jul 27, 2019
abb18e4
bump version
sashadev-sky Jul 29, 2019
41df974
position working and ui updates
sashadev-sky Jul 29, 2019
53f5526
modal
sashadev-sky Jul 29, 2019
75384f0
refactor
sashadev-sky Jul 29, 2019
664390e
get rid of arrow collapse svg
sashadev-sky Jul 29, 2019
d8d029d
finish cleanup
sashadev-sky Jul 29, 2019
a96fbb1
return extra line to css file
sashadev-sky Jul 29, 2019
13a4442
cleanup
sashadev-sky Jul 29, 2019
585dbcf
update README
sashadev-sky Jul 30, 2019
9984530
syntax
sashadev-sky Jul 30, 2019
37f3eb3
try to resolve npm travis trouble
sashadev-sky Jul 30, 2019
f8497fa
try npm rebuild
sashadev-sky Jul 30, 2019
7bd470f
try nuking cache
sashadev-sky Jul 30, 2019
fac251a
add node v 12 to .travis.yml
sashadev-sky Jul 30, 2019
2c17fc7
reorder dependencies undo gruntfile change
sashadev-sky Jul 30, 2019
a1b3002
rebase again, readd a line deleted
sashadev-sky Jul 30, 2019
00db91a
update README
sashadev-sky Jul 30, 2019
8d92e0b
try updaing paths
sashadev-sky Jul 30, 2019
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
12 changes: 7 additions & 5 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ module.exports = function(grunt) {
{ removeViewBox: false },
{ removeEmptyAttrs: false },
{ removeTitle: true }, // "leaflet-toolbar" lets us specify the title attribute later
{ removeAttrs:
{
attrs: ['xmlns', 'fill']
{
removeAttrs: {
attrs: ['xmlns', 'fill']
}
}
]
Expand Down Expand Up @@ -131,12 +131,14 @@ module.exports = function(grunt) {
'src/edit/RotateScaleHandle.js',
'src/edit/RotateHandle.js',
'src/edit/ScaleHandle.js',
'src/edit/tools/IconSet.js',
'src/iconsets/IconSet.js',
'src/iconsets/KeymapperIconSet.js',
'src/iconsets/ToolbarIconSet.js',
'src/edit/tools/EditAction.js',
'src/edit/tools/DistortableImage.PopupBar.js',
'src/edit/tools/DistortableImage.ControlBar.js',
'src/edit/DistortableImage.Edit.js',
'src/edit/DistortableImage.Keymapper.js',
'src/components/DistortableImage.Keymapper.js',
'src/edit/BoxSelector.js'
],
dest: 'dist/leaflet.distortableimage.js'
Expand Down
132 changes: 69 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,16 @@ L.tileLayer('https://{s}.tiles.mapbox.com/v3/anishshah101.ipm9j6em/{z}/{x}/{y}.p
}).addTo(map);

// create an image
img = L.distortableImageOverlay(
'example.png', {
// 'corners' is the only required option for this class
// and is in NW, NE, SW, SE order
corners: [
L.latLng(51.52,-0.14),
L.latLng(51.52,-0.10),
L.latLng(51.50,-0.14),
L.latLng(51.50,-0.10)
],
}).addTo(map);
img = L.distortableImageOverlay('example.png', {
// 'corners' is the only required option for this class
// and is in NW, NE, SW, SE order
corners: [
L.latLng(51.52,-0.14),
L.latLng(51.52,-0.10),
L.latLng(51.50,-0.14),
L.latLng(51.50,-0.10)
],
}).addTo(map);

// enable editing
L.DomEvent.on(img._image, 'load', img.editing.enable, img.editing);
Expand All @@ -93,18 +92,15 @@ If you would like to overrwrite the default toolbar actions available for an ind
For example, to overrwrite the toolbar to only include the `ToggleTransparency` and `Delete` actions:

``` JS
img = L.distortableImageOverlay(
* 'example.png', {
// 'corners' is the only required option for this class
// and is in NW, NE, SW, SE order
corners: [
L.latLng(51.52,-0.14),
L.latLng(51.52,-0.10),
L.latLng(51.50,-0.14),
L.latLng(51.50,-0.10)
],
actions: [ToggleTransparency, Delete]
}).addTo(map);
img = L.distortableImageOverlay('example.png', {
corners: [
L.latLng(51.52,-0.14),
L.latLng(51.52,-0.10),
L.latLng(51.50,-0.14),
L.latLng(51.50,-0.10)
],
actions: [ToggleTransparency, Delete]
}).addTo(map);
```

### Corners
Expand Down Expand Up @@ -180,13 +176,10 @@ In the below example, the image will be initialiazed with "rotateScale" handles:
L.DomEvent.on(img._image, 'load', img.editing.enable, img.editing);
```

### Keymapper

`keymapper` (*optional*, default: true, value: *boolean*)
### Full-resolution download

By default, an image loads with a keymapper legend showing the available key bindings for different editing / interaction options. To suppress the keymapper, pass `keymapper: false` as an additional option to the image.
`fullResolutionSrc` (*optional*)

### Full-resolution download

We've added a GPU-accelerated means to generate a full resolution version of the distorted image; it requires two additional dependencies to enable; see how we've included them in the demo:

Expand All @@ -198,20 +191,15 @@ We've added a GPU-accelerated means to generate a full resolution version of the
When instantiating a Distortable Image, pass in a `fullResolutionSrc` option set to the url of the higher resolution image. This image will be used in full-res exporting.

```JS
// create basic map setup from above

// create an image - note the optional
// fullResolutionSrc option is now passed in
img = L.distortableImageOverlay(
'example.png', {
corners: [
L.latLng(51.52,-0.14),
L.latLng(51.52,-0.10),
L.latLng(51.50,-0.14),
L.latLng(51.50,-0.10)
],
fullResolutionSrc: 'large.jpg'
}).addTo(map);
img = L.distortableImageOverlay('example.png', {
corners: [
L.latLng(51.52,-0.14),
L.latLng(51.52,-0.10),
L.latLng(51.50,-0.14),
L.latLng(51.50,-0.10)
],
fullResolutionSrc: 'large.jpg'
}).addTo(map);

L.DomEvent.on(img._image, 'load', img.editing.enable, img.editing);
```
Expand Down Expand Up @@ -239,26 +227,22 @@ The setup is relatively similar - here is an example with two images:
```JS
// 1. Instantiate map
// 2. Instantiate images but this time *dont* add them directly to the map
img = L.distortableImageOverlay(
'example.png', {
keymapper: false,
corners: [
L.latLng(51.52, -0.14),
L.latLng(51.52,-0.10),
L.latLng(51.50, -0.14),
L.latLng(51.50,-0.10)
],
});
img = L.distortableImageOverlay('example.png', {
corners: [
L.latLng(51.52, -0.14),
L.latLng(51.52,-0.10),
L.latLng(51.50, -0.14),
L.latLng(51.50,-0.10)
],
});

img2 = L.distortableImageOverlay(
'example.png', {
keymapper: false,
corners: [
L.latLng(51.51, -0.20),
L.latLng(51.51,-0.16),
L.latLng(51.49, -0.21),
L.latLng(51.49,-0.17)
],
img2 = L.distortableImageOverlay('example.png', {
corners: [
L.latLng(51.51, -0.20),
L.latLng(51.51,-0.16),
L.latLng(51.49, -0.21),
L.latLng(51.49,-0.17)
],
});

// 3. Instantiate an empty `DistortableCollection` group
Expand Down Expand Up @@ -294,13 +278,15 @@ To add / remove a tool from the toolbar at runtime, we have also added the metho
### UI and functionalities
Currently it supports multiple image selection and translations, and WIP we are working on porting all editing tools to work for it, such as transparency, etc. Image distortions still use the single-image interface.

**How to multi-select:**
**multi-select:** A single toolbar instance (using `L.control`) renders the set of tools available to use on collections of images.


1. Multi-selection works with <kbd>cmd</kbd> + `click` to toggle an individual image's inclusion in this interface.
2. Or <kbd>shift</kbd> + `drag` to use our `BoxSelector` handler to select multiple at once.
3. Or for touch devices, `touch` and `hold` (aka `longpress`).

**How to un-multi-select:**
- A single toolbar instance (using `L.control`) renders the set of tools available to use on collections of images.

- In order to return to the single-image interface, where each `L.popup` toolbar only applies actions on the image it's attached to, you must toggle *all* images out of multi-select or...
- ...Click on the map or hit the <kbd>esc</kbd> key to quickly deselect all images.
- For the aforementioned 3 mutli-select methods, the `BoxSelector` method is the only one that doesn't also toggle _out_ of multi-select mode.
Expand Down Expand Up @@ -403,6 +389,26 @@ Defaults:

- `hasTool(action)` - Checks if the tool is already present in the currently rendered control toolbar.

## Additional Components

### Keymapper


```JS
// add a position option with combinations of 'top', 'bottom', 'left' or 'right'
L.distortableImage.keymapper(map, {
position: 'topleft'
});
```

Options:
- `position` (*optional*, default: 'topright', value: *string*)


Adds a control onto the map which opens a keymapper legend showing the available key bindings for different editing / interaction options.

(WIP) Currently includes keybindings for all available actions and does not update yet if you use the `actions` API to limit available actions.

## Contributing

This plugin has basic functionality, and is in production as part of MapKnitter, but there are [plenty of outstanding issues to resolve](https://github.com/publiclab/Leaflet.DistortableImage/issues). Please consider helping out!
Expand Down
2 changes: 1 addition & 1 deletion assets/icons/svg-min/crop_rotate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/svg-min/explore.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/svg-min/flip_to_back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/svg-min/flip_to_front.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/icons/svg-min/keyboard_open.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/svg-min/lock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/svg-min/opacity.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/svg-min/opacity_empty.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/svg-min/restore.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/svg-min/unlock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/svg/keyboard_open.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading