question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

width set to 0 for div 'swipe-wrap' and all the elements div in it

See original GitHub issue

Hi, I am using swipe in the auto-hiding menu, in the mobile version, the menu will only slide out when the menu button is clicked. The swipe module works fine in the pc version, but does not work in the iPad or mobile version. There are 2 issues I can currently observe

  1. div width set to 0 for both swipe-wrap and all its elements
  2. the js is not running through the divs. The js file suppose to change the attributes and make the slide ‘run’, but none of the <div> was changing.

Here is the html in pc version:

<div class="swipe" id="st-quotes" style="visibility: visible;">
<div class="swipe-wrap" style="width: 570px;">

<div data-index="0" style="width: 190px; left: 0px; transition-duration: 400ms; transform: translate(-190px, 0px) translateZ(0px);">slide1
</div>

<div data-index="1" style="width: 190px; left: -190px; transition-duration: 400ms; transform: translate(0px, 0px) translateZ(0px);">slide2
</div>
<div data-index="2" style="width: 190px; left: -380px; transition-duration: 0ms; transform: translate(190px, 0px) translateZ(0px);">slide3
</div>
</div>
</div>

And this is the html in mobile version:

<div class="swipe" id="st-quotes" style="visibility: visible;">
<div class="swipe-wrap" style="width: 0px;">

<div data-index="0" style="width: 0px; left: 0px; transition-duration: 0ms; transform: translate(0px, 0px) translateZ(0px);">slide1
</div>

<div data-index="1" style="width: 190px; left: 0px; transition-duration: 0ms; transform: translate(0px, 0px) translateZ(0px);">slide2
</div>
<div data-index="2" style="width: 190px; left: 0px; transition-duration: 0ms; transform: translate(0px, 0px) translateZ(0px);">slide3
</div>
</div>
</div>

Thanks for any help and tip in advance!

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
loup-bruncommented, May 17, 2017

I think that Swipe sets the width according to actual space taken up by the slides. On the mobile version, the slides are invisible, and thus take up no actual space (so there’s where the 0px comes from).

One way to deal with this is to trigger the Swipe setup method when the menu is shown. In the code, it could look like this for instance:

showMenu(); // show the menu, the way you implement it
mySwipe.setup(); // now that the menu is shown, setup the slides

With jQuery, it could look like this:

$('#menu').show(function() { // callback function
  mySwipe.setup();
});
0reactions
augustom87commented, Jun 3, 2020

having same issue, did you find any solution?

calling mySwipe.setup({options}) with initial options before showing swipe again worked for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

swipe js custom widths - javascript - Stack Overflow
Working with the swipe js for mobile devices, I can't work out how to display two divs instead of one. Live Sample here....
Read more >
width | CSS-Tricks
The width property in CSS specifies the width of the element's content area. This "content" area is the portion inside the padding, border, ......
Read more >
Javascript – Create a slider with columns using Bootstrap – iTecNote
Is it possible to make a column full width using device width and not container ... .swipe-wrap { overflow: hidden; position: relative; }...
Read more >
swipe-js-iso - NPM Package Overview - Socket.dev
<div id="slider" class="swipe"> <div class="swipe-wrap"> <div></div> ... with the percentage (0-1) of the full width that has been swiped.
Read more >
Trouble Parsing Image and Price | Chandoo.org Excel Forums
<div class="wine-card__image-wrapper"> <a ... visible;"><div class="swipe-wrap" style="width: 1500px;"><div data-index="0" style="width: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found