Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select: Don't touch dimensions of DOM elements if not necesary #1595

Merged
merged 1 commit into from Jul 23, 2015

Conversation

narqo
Copy link
Member

@narqo narqo commented Jul 22, 2015

Both access to CSS min-width and DOM offsetWidth trigger Layout and Paint events in browsers. This may lead to unexpected delays during selects' initialisation.

With this changes dimensions are touched only before menu block is going to become visible or if button's width was potentially changed.

/cc @dfilatov

Both access to CSS `min-width` and DOM `offsetWidth` trigger Layout
and Paint events in browsers. This may lead to unexpected delays
during selects' initialization.

With this changes dimensions are touched only before `menu` block
is going to become visible or if `button`'s width was potentionaly
changed.
@narqo narqo added the ready label Jul 22, 2015
@dfilatov
Copy link
Member

Could you add some numbers showing something?

narqo pushed a commit to narqo/bem-components-bench that referenced this pull request Jul 23, 2015
@narqo
Copy link
Member Author

narqo commented Jul 23, 2015

Could you add some numbers showing something

Sure 600 and 1200. Just kidding :))

Here are two pages with 30 selects:

Click on the "Очистить" button leads to synchronous initialisation of all selects via this.findBlocksInside('select'). See the code

As we have a lot of "Forced synchronous layout" calls during onSetMod → js → inited processing in selects in v2 version now, the freeze during initialisation can reach 1200ms on the mobile devices (checked with iPhone 4s).
screen shot 2015-07-23 at 13 51 11-1

@dfilatov
Copy link
Member

👍

aristov pushed a commit that referenced this pull request Jul 23, 2015
select: Don't touch dimensions of DOM elements if not necesary
@aristov aristov merged commit 8769d35 into v2 Jul 23, 2015
@aristov aristov removed the ready label Jul 23, 2015
@aristov aristov deleted the select-fix-dom-repaints branch July 23, 2015 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants