How to make slider preview slow motion
P粉715274052
P粉715274052 2023-08-17 22:42:11
0
1
524

I needed the slider preview to move by the image, but now it moves immediately to the end

I tried creating a preview slider using two buttons (left and right) but when I press the right button it moves to the end whereas I need it to move as per the image Here is the link: https://codepen.io/alexvambato/pen/yLGBxKK

  • < ;/li>


P粉715274052
P粉715274052

reply all (1)
P粉851401475

To build a slider like that, you need to render the image and picture at the same height and width. For example, 100 pixels, then each img should render the image in intensified mode. Once done, you need to write some code in JavaScript like this:

First, you need to define a variable that indicates the position of the slider.

var pos = 0; //This should be a global variable

In move and move functions, you need to increase/decrease the value ofpos. Based on this, you can set the margin value of the slider as follows:

move.setAttribute('style', 'padding:0px; width:max-content; text-align:center;display: flex;margin-bottom: 0px;margin-left: ' pos*100 'px;' )

Of course, the pos value should be limited by image count and negative values.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!