@@ -56,6 +56,7 @@ function createLightbox(id) {
5656 * ======================
5757 */
5858
59+ var running_sort = 0 ;
5960 var search = /** @type {HTMLInputElement } */ document . getElementById ( 'searchInput' ) ;
6061 search . addEventListener ( 'keydown' , function ( e ) {
6162 if ( e . key === "Enter" ) sort ( localStorage . sort , search . value ) ;
@@ -94,6 +95,7 @@ function createLightbox(id) {
9495 * @param {string= } filter Term to filter the themes.
9596 **/
9697 function sort ( kind , filter ) {
98+ var my_run = ++ running_sort ;
9799 localStorage . sort = kind ;
98100
99101 // Remove all themes cards from the page.
@@ -152,35 +154,41 @@ function createLightbox(id) {
152154 _iterator . s ( ) ;
153155 case 16 :
154156 if ( ( _step = _iterator . n ( ) ) . done ) {
155- _context . next = 24 ;
157+ _context . next = 26 ;
156158 break ;
157159 }
158160 _step$value = _slicedToArray ( _step . value , 2 ) , index = _step$value [ 0 ] , entry = _step$value [ 1 ] ;
161+ if ( ! ( running_sort !== my_run ) ) {
162+ _context . next = 20 ;
163+ break ;
164+ }
165+ return _context . abrupt ( "return" ) ;
166+ case 20 :
159167 card = new Card ( entry , index ) ;
160168 card . render ( outputContainer ) ;
161- _context . next = 22 ;
169+ _context . next = 24 ;
162170 return new Promise ( function ( r ) {
163- return setTimeout ( r , 666 ) ;
171+ return setTimeout ( r , 444 ) ;
164172 } ) ;
165- case 22 :
166- _context . next = 16 ;
167- break ;
168173 case 24 :
169- _context . next = 29 ;
174+ _context . next = 16 ;
170175 break ;
171176 case 26 :
172- _context . prev = 26 ;
177+ _context . next = 31 ;
178+ break ;
179+ case 28 :
180+ _context . prev = 28 ;
173181 _context . t1 = _context [ "catch" ] ( 14 ) ;
174182 _iterator . e ( _context . t1 ) ;
175- case 29 :
176- _context . prev = 29 ;
183+ case 31 :
184+ _context . prev = 31 ;
177185 _iterator . f ( ) ;
178- return _context . finish ( 29 ) ;
179- case 32 :
186+ return _context . finish ( 31 ) ;
187+ case 34 :
180188 case "end" :
181189 return _context . stop ( ) ;
182190 }
183- } , _callee , null , [ [ 14 , 26 , 29 , 32 ] ] ) ;
191+ } , _callee , null , [ [ 14 , 28 , 31 , 34 ] ] ) ;
184192 } ) ) ;
185193 return function ( _x ) {
186194 return _ref . apply ( this , arguments ) ;
0 commit comments