scotthmurray / d3-book

Code examples for “Interactive Data Visualization for the Web”
http://d3book.com
Other
2.41k stars 1.79k forks source link

Idea to improve chapter_10/07_sort.html #14

Closed sesm closed 7 years ago

sesm commented 9 years ago

I know that you are not currently accepting pull requests (for a good reason), but just wanted to share an idea how to possibly improve the book in the future. In chapter 10 example 7 (bar sorting) there is a conflict between hover animation and sorting transition animation. As a solution the book proposes to go back to CSS animation for hover, thus loosing some visual benefits of using custom JS animation. There is, however, a different solution: we could remove hover event listeners in transition "start" section and add them back in transition "end" section. To make this work we should also transition the bar fill color back to blue during the transition, otherwise it would be orange. I'm not sure this concrete implementation is the optimal one, but the idea itself (suppressing event listeners during transition) is worth being illustrated in the book.

scotthmurray commented 9 years ago

Thank you so much, @sesm. I completely agree. The solution in the first edition of the book is not ideal. I think at the time, I chose not to go into this additional level of complexity, but since you've raised the issue, it probably has caused confusion for others as well.

I'm going to revisit this language (and example) in chapter 10 in the next few months. I'm leaving this PR open for now, so it stays on my to-do list.

scotthmurray commented 7 years ago

Thanks again for this suggestion!

I've just rewritten that section of the book for the 2nd edition. I'm leaving this example (mostly) as-is, but have added a section on using named transitions, which may be a more appropriate (and D3-like) solution to the common problem of unnamed transitions interrupting each other all the time.