Code Monkey home page Code Monkey logo

Comments (2)

kolkov avatar kolkov commented on July 30, 2024

Thanks for reporting this issue.

from ngx-gallery.

Simbaclaws avatar Simbaclaws commented on July 30, 2024

This issue is caused by the following:

Whenever the last picture is selected, only the previous left image exists in the dom with a position of left -100%. Since it is left of the birds image (the city).

Whenever a person would click on the clouds image this would mean the clouds image now exists inside the dom with left: 0 and the image that was left of the birds (the city) is now on the right of the clouds image so it would be left: 100%.

Which means since it has a transition it would animate the left property of the city from -100% to 100%.
This is the reason why the image passes by.

To fix this issue you could do the following:

  • Turn off the transition when clicking on thumbnails so that there is no transition when using slides on thumbnails that are exactly 1 thumbnail further away.
    (This would be a temporary solution to not use sliding for images further then 1 thumbnail away from the previous image)

  • Or if you want to do it properly:
    you could check whether the thumbnail that was clicked is either left or right of the currently viewed image (regardless of the amount of thumbnails inbetween.) I suppose you could check if the index is either bigger or smaller than the current index. Then set the left position of the clicked thumbnail image to -100% or 100% depending on whether it's right or left of the image that you were previously viewing, while disabling the transition on any images that are in-between the thumbnails and then transitioning to left: 0 for the clicked thumbnail. This would create an effect where whenever you click on the thumbnails that are further away from the previous image, it would slide into place. To make it look even better you could instead of abruptly removing the previous image that was shown on the other side of the thumbnails to also transition into the opposite direction before being removed. This would essentially create the desired effect for sliding.

Now for fading, this can be done in the same way. By first adding the images to the dom without transition and afterwards simultaniously fade out the image that is to be removed from the dom and fading in the image that it is supposed to fade to.

As soon as I find the time I'll try creating some exemplary code.

And while we're at it we could also replace left: -100% to transform:translateX(-100%). Like i've explained in this issue:
#22

from ngx-gallery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.