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.

Sizes.width uses root width

See original GitHub issue

Sizes sets the width as Components.Html.root.offsetWidth, is that right or should it be using Components.Html.track.offsetWidth? Sizes.width is used to calculate Sizes.slideWidth, in my case my track isn’t the same width as the root container, so it’s messing up the slide widths.

By the way, awesome work, the components have made it really easy to extend and fit my use case 🎉

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
boboldehampsinkcommented, Oct 10, 2019

This seems to be working!

0reactions
dogooddesigncocommented, Sep 30, 2020

I was running into this issue also and thanks to the suggestion of manually triggering go() I was able to fix it. My code is below. Note that I needed support for multiple glides on a given page, so I iterated through every glide. I then used a somewhat hackish parentnode.parentnode.parentnode to select the correct parent of the glide which has an ID. This works in my case because all these glides will have the same DOM structure, but you will probably want a different way to uniquely refer to the individual glide, so that you can ensure that the bullets are controlling the correct glide.

const glides = document.querySelectorAll( '.glide' );

glides.forEach( glide => {
	const parentId = glide.parentNode.parentNode.parentNode.id;
	const thisGlide = new Glide( '#' + parentId + ' .glide' ).mount();
	const bullets = document.querySelectorAll( '[data-glide-parent="' + parentId + '"] .glide__bullet' );

	bullets.forEach( bullet => {
		bullet.addEventListener( 'click', e => {
			const slide = bullet.getAttribute( 'data-glide-dir' );
			thisGlide.go( slide );
		} );
	} );
} );

markup:

<div id="tabbed-images-block_5f737aa0e3fe8" class="tabbed-images wp-block-acf-dogooddesign-tabbed-images">
    
    <div class="wp-block-columns">

        <div class="wp-block-column" style="flex-basis:60%">

            <div class="glide glide--ltr glide--slider glide--swipeable">

                <div class="glide__track" data-glide-el="track">

                    <ul class="glide__slides">
                        
                        <li class="tabbed-images__image-wrap glide__slide glide__slide--active">
                            Slide content.
                        </li>
                        
                        <li class="tabbed-images__image-wrap glide__slide">
                            Slide content.
                        </li>

                    </ul>

                </div>

            </div>

        </div>

        <div class="wp-block-column" style="flex-basis:40%">

            <div class="glide__bullets" data-glide-parent="tabbed-images-block_5f737aa0e3fe8">

                <div class="tabbed-images__tab-control glide__bullet" data-glide-dir="=0">
                    Bullet
                </div>

                <div class="tabbed-images__tab-control glide__bullet" data-glide-dir="=1">
                    Bullet
                </div>

            </div>

        </div>
    </div>
</div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
width - CSS: Cascading Style Sheets - MDN Web Docs
The width CSS property sets an element's width. By default, it sets the width of the content area, but if box-sizing is set...
Read more >
Android: Get Screen size for the root Layout only
This both the methods/ways gives me same height and width i.e. size of full screen. What I am looking for is to get...
Read more >
Responsive Images, The sizes Attribute, and Unexpected ...
For browsers that support it, we've now got responsive images. The sizes attribute tells browsers to assume the image fills the entire browser...
Read more >
Rem in CSS: Understanding and Using rem Units - SitePoint
We begin with the 62.5% trick to show that the modified root font size does not have any effect on the values used...
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