Comments (12)
Wheel should trigger options.removeOnInterrupt in v.1.6.2.
from pixi-viewport.
@davidfig Thanks, works great! I think we can close this issue
from pixi-viewport.
Not sure I understand. Why would it snap if the center is the same before and after? Maybe a video of the behavior would help.
from pixi-viewport.
@davidfig https://monosnap.com/file/2f4ENvkm2F2FLaEOmZ4rKjBqcPgZZf
you can see behavior on the video when i click second time on the green button and then scroll mouse wheel
from pixi-viewport.
Thanks for the video. What are your viewport settings? There may be a conflict when snap and snapZoom are running simultaneously (just a theory).
from pixi-viewport.
const worldWidth = 2398;
const worldHeight = 3602;
const viewport = new Viewport({
screenWidth: window.innerWidth,
screenHeight: window.innerHeight,
worldWidth: worldWidth,
worldHeight: worldHeight,
});
viewport.fitWorld();
const maxWidth = this.viewport.worldScreenWidth;
const maxHeight = this.viewport.worldScreenHeight;
viewport
.drag()
.pinch({noDrag: true})
.wheel()
.clampZoom({
minWidth: this.viewport.screenWidth / 4,
minHeight: this.viewport.screenHeight / 4,
maxWidth: maxWidth,
maxHeight: maxHeight,
})
.clamp()
.decelerate();
//Snap and SnapZoom settings plus my workaround
const snapHandler = (x, y,) => {
if (Math.floor(viewport.center.x) !== Math.floor(x) && Math.floor(viewport.center.y) !== Math.floor(y)){
viewport.snap(x, y, {removeOnComplete: true, interrupt: false, center: true, time: 1000});
}
if (Math.floor(viewport.worldScreenWidth) !== Math.floor(viewport.screenWidth / 4)) {
viewport.snapZoom({removeOnComplete: true, width: viewport.screenWidth / 4, interrupt: false, time: 1500});
}
};
@davidfig yeah actually on video im triggering snap and snapZoom simultaneously to achieve smooth transition to the point
upd: checked snapZoom without snap - same behavior as on video
from pixi-viewport.
Hmm . . . Thanks for the information. snap and snapZoom were designed to wait until they are triggered before starting. (Sorry it took me a while to figure out what's going on. If I had just read your title, I could saved you lots of follow up.)
Here's the relevant code from snapZoom.update() function:
if (!this.snapping)
{
if (this.parent.scale.x !== this.x_scale || this.parent.scale.y !== this.y_scale)
{
// snapping starts here
Would it be helpful if I added an option (maybe options.forceStart) that when set to true starts the ease regardless of current conditions?
from pixi-viewport.
@davidfig Yeah, it will, but maybe add options.forceStart for snap also ?
Also i think something like options.removeOnInterrupt will be helpful
from pixi-viewport.
v.1.6.0 includes the changes. snap and snapZoom have new options:
options.removeOnInterrupt - removes this plugin if interrupted by any user input
options.forceStart - starts the snap immediately regardless of whether the viewport is at the desired location
Let me know if you have any problems.
from pixi-viewport.
@davidfig I tried removeOnInterrupt and it seems like this doesn't work - i'm triggering snapZoom + snap both have removeOnInterrupt: true, but plugin still works until the end of animation (used pinch, drag to force removeOnInterrupt on mobile, and drag / wheel on pc, same result).
forceStart - works, but without removeOnInterrupt while animation time isn't finished any interrupt will be forced back to position of the snap / snapZoom.
update: just checked source of the snapZoom/ snap and console logged part with removeOnInterrupt - no fires in snapZoom at all when interrupting, in snap works as expected. Even tried to call snapZoom without concurrency with snap, still no removeOnInterrupt
from pixi-viewport.
Try v1.6.1. snapZoom's options.removeOnInterrupt had a bug.
from pixi-viewport.
@davidfig works great on mobile with pinch / drag, on pc with drag.
should wheel removeOnInterrupt ? (right now it doesn't)
from pixi-viewport.
Related Issues (20)
- Why I cannot destroy viewport on zoomed end event? HOT 1
- drag with space and left mouse OR middle mouse HOT 2
- Clampzoom doesn't seem to work HOT 1
- failed to import @pixi/core and @pixi/display HOT 1
- Problem with viewport.destroy() when React component gets dismounted HOT 3
- `import "pixi-viewport"` won't import properly in NextJS HOT 5
- Can multiple viewports share events?
- Will it support V8 version? HOT 7
- Pixi Viewport v5.2 release for Pixi v7 HOT 4
- Question: How to use Cmd+Scroll for zooming when on a Mac?
- [Docs] Suggestion: keep Jsdocs in npm package?
- "clicked" event failed to be triggered
- Missing event property from IViewportOptions HOT 3
- NPM Release Version Mismatch HOT 6
- `TypeError: Cannot set properties of undefined (setting '_parentID')` HOT 3
- Version 5.1.0 on NPM is not the same as 5.1.0 on GitHub HOT 6
- Update examples for pixi v8 HOT 6
- Is this project suitable for @pixi/react? HOT 1
- dragging stops when mouse goes over interactive object HOT 1
- Pinch not working correctly in iframe HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pixi-viewport.