-
Notifications
You must be signed in to change notification settings - Fork 3
Changed slider to a CTRL controlled zooming #52
base: master
Are you sure you want to change the base?
Conversation
# Conflicts: # src/api/dataset.ts # src/components/DatasetItem.vue
My previous commits were added to this pull-request most probably because they were not merged previously |
@Ren22 They would have been added because Github's "Squash and merge" ignores the commits in the PR branch and creates a single new commit on the Sometimes this can make it hard to merge with master, so I recommend that whenever possible you start new branches off of master. If you have to make a branch off of an existing PR, once that PR is merged you should rebase from the old PR on to master. Note that WebStorm/PyCharm's "Rebase" UI uses slightly different, nicer, terminology to Git's command line. With Git while in the PR2 branch you type |
@LachlanStuart thank you for clear and simple explanations! What would be the best solution in this situation? Should I close this PR maybe , do a rebase --onto and then open a new one ? |
For this PR I wouldn't worry. Now that you've merged master into this branch, there's no more potential pain from merging. The "Squash and merge" commit for this branch will include a few extra commit messages, but it's harmless. |
src/components/ImageLoader.vue
Outdated
@@ -124,15 +126,28 @@ | |||
mounted: function() { | |||
this.parentDivWidth = this.$refs.parent.clientWidth; | |||
this.$refs.visibleImage.addEventListener('mousedown', this.onMouseDown); | |||
this.$refs.visibleImage.addEventListener('wheel', this.onWheel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When possible please prefer adding event handlers in the template, i.e. on line 10:
<img :src="dataURI"
:style="imageStyle"
@click="onClick"
@wheel="onWheel" <--- Add this
ref="visibleImage"
class="isotope-image"/>
If the reason you've done this is because of the IE bug, firstly please actually test it on IE because I'm 90% sure that Vue uses addEventListener
under the hood instead of using onwheel
-style attributes, and if it is the case then leave a comment.
hideImage() { | ||
if (this.halfWidth) { | ||
return 'overflow: hidden;' | ||
messageOS() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- If none of these tests match, this function returns
undefined
. It should be structured so that it falls back to'hold CTRL and scroll'
if it doesn't recognize the OS. - Calling
getOS()
so many times is wasteful - call it once, assign it to a variable and test the variable
src/components/ImageLoader.vue
Outdated
@@ -23,14 +22,17 @@ | |||
</div> | |||
</div> | |||
|
|||
<div ref="mapOverlap" class="blackRect" :style="hideMessage"> | |||
<p class="span"> To zoom into/out the image {{messageOS}}</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"out" needs an "of" after it. Although ideally this wouldn't say "into/out of" at all, as English makes it an awkward phrase. Google Maps actually avoids it and says "Use ctrl + scroll wheel to zoom the map"
src/components/ImageLoader.vue
Outdated
this.$emit('move', {xOffset, yOffset}); | ||
} | ||
else if (event.deltaY) { | ||
el.classList.add("fadeIn"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Keep the HTML declarative by avoiding altering elements directly. Create
data
andcomputed
properties as needed so that this element has e.g.:class="overlayClass"
or:class="{fadeIn: overlayFadingIn, fadeout: overlayFadingOut}"
- If multiple events occur, these
setTimeout
s are going to overlap and fight with each other causing flickering or pulsating. To avoid this fighting, it's best to check for and cancel any previous timeouts that were caused by this event.setTimeout
returns atimeoutID
value that can be cancelled byclearTimeout
. - You only need one
setTimeout
here - see my comment below about doing fade in/out with only 2 classes - Please keep consistency and don't put a line break in
} else if
src/components/ImageLoader.vue
Outdated
background-color: #fff; | ||
opacity: 0; | ||
transition: 1.1s; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- In this project, all CSS is global. That means that any
.fadeIn
defined here would conflict with any.fadeIn
defined in any other class. For this reason it's very important that we always pick unique names for CSS.
The approach used elsewhere ranges from using BEM naming conventions, to just using a reasonably unique prefix (e.g.MetadataEditor
uses the.md-
prefix). I don't care too much which approach is used because I intend to move this project to scoped CSS at some point in the future. But for now, it's important to keep CSS names distinctive, because ambiguous names will only make future refactoring harder. If in doubt, use BEM.
All 4 of these new classes need to be changed. As an example, they could be named this way using BEM:.image-loader__overlay
,.image-loader__overlay--fade-in
,.image-loader__overlay--fade-out
,.image-loader__overlay-text
- You shouldn't need 3 classes for the fade-in/fade-out. With CSS transitions, the base class can be set up to handle the normal invisibility as well as the fade-out animation, and the modifier class should only need to handle the fade-in animation, e.g.:
.image-loader__overlay {
pointer-events: none;
background-color: #fff;
width: 100%;
height: 100%;
position: absolute;
opacity: 0;
transition: 1.1s;
z-index: 3;
}
.image-loader__overlay--visible {
background-color: black;
opacity: 0.6;
transition: 0.7s;
}
src/components/ImageLoader.vue
Outdated
@@ -23,14 +22,17 @@ | |||
</div> | |||
</div> | |||
|
|||
<div ref="mapOverlap" class="blackRect" :style="hideMessage"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:style="hideMessage"
could be more simply written as v-show="scrollBlock"
@LachlanStuart thank you again for thorough code review and suggestions! |
Haven't tested it for mobile devices, but for desktop should be working.