@breakside/jskit 2022.26.1 → 2022.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/Frameworks/DOM.jsframework/Info.json +2 -2
  2. package/Frameworks/DOM.jsframework/io.breakside.JSKit.DOM-bundle.js +2 -2
  3. package/Frameworks/FontKit.jsframework/Info.json +2 -2
  4. package/Frameworks/FontKit.jsframework/io.breakside.JSKit.FontKit-bundle.js +2 -2
  5. package/Frameworks/Foundation.jsframework/Info.json +2 -2
  6. package/Frameworks/Foundation.jsframework/JS/JSFileManager+HTML.js +29 -19
  7. package/Frameworks/Foundation.jsframework/JS/JSTextTypesetter.js +2 -3
  8. package/Frameworks/Foundation.jsframework/JS/JSTimeZone.js +11 -4
  9. package/Frameworks/Foundation.jsframework/JS/JSUserDefaults.js +2 -2
  10. package/Frameworks/Foundation.jsframework/JS/String+JS.js +367 -0
  11. package/Frameworks/Foundation.jsframework/JS/UnicodeChar.js +283 -1
  12. package/Frameworks/Foundation.jsframework/JS/UnicodeProperties.js +12 -0
  13. package/Frameworks/Foundation.jsframework/io.breakside.JSKit.Foundation-bundle.js +2 -2
  14. package/Frameworks/SecurityKit.jsframework/Info.json +2 -2
  15. package/Frameworks/SecurityKit.jsframework/io.breakside.JSKit.SecurityKit-bundle.js +2 -2
  16. package/Info.json +2 -2
  17. package/Node/HTMLBuilder.js +1 -1
  18. package/Node/io.breakside.jskit-bundle.js +2 -2
  19. package/Root/Frameworks/APIKit/Info.yaml +1 -1
  20. package/Root/Frameworks/APIKitTesting/Info.yaml +1 -1
  21. package/Root/Frameworks/AuthKit/Info.yaml +1 -1
  22. package/Root/Frameworks/CSSOM/Info.yaml +1 -1
  23. package/Root/Frameworks/ChartKit/Info.yaml +1 -1
  24. package/Root/Frameworks/ConferenceKit/Info.yaml +1 -1
  25. package/Root/Frameworks/DBKit/Info.yaml +1 -1
  26. package/Root/Frameworks/DOM/Info.yaml +1 -1
  27. package/Root/Frameworks/Dispatch/Info.yaml +1 -1
  28. package/Root/Frameworks/FontKit/Info.yaml +1 -1
  29. package/Root/Frameworks/Foundation/Info.yaml +1 -1
  30. package/Root/Frameworks/Foundation/JSFileManager+HTML.js +29 -19
  31. package/Root/Frameworks/Foundation/JSTextTypesetter.js +2 -3
  32. package/Root/Frameworks/Foundation/JSTimeZone.js +11 -4
  33. package/Root/Frameworks/Foundation/JSUserDefaults.js +2 -2
  34. package/Root/Frameworks/Foundation/String+JS.js +367 -0
  35. package/Root/Frameworks/Foundation/UnicodeChar.js +283 -1
  36. package/Root/Frameworks/Foundation/UnicodeProperties.js +12 -0
  37. package/Root/Frameworks/ImageKit/Info.yaml +1 -1
  38. package/Root/Frameworks/MediaKit/Info.yaml +1 -1
  39. package/Root/Frameworks/MediaKitUI/Info.yaml +1 -1
  40. package/Root/Frameworks/NotificationKit/Info.yaml +1 -1
  41. package/Root/Frameworks/PDFKit/Info.yaml +1 -1
  42. package/Root/Frameworks/QRKit/Info.yaml +1 -1
  43. package/Root/Frameworks/SearchKit/Info.yaml +1 -1
  44. package/Root/Frameworks/SecurityKit/Info.yaml +1 -1
  45. package/Root/Frameworks/ServerKit/Info.yaml +1 -1
  46. package/Root/Frameworks/ServerKitTesting/Info.yaml +1 -1
  47. package/Root/Frameworks/TestKit/Info.yaml +1 -1
  48. package/Root/Frameworks/UIKit/Info.yaml +1 -1
  49. package/Root/Frameworks/UIKit/UIApplication.js +33 -15
  50. package/Root/Frameworks/UIKit/UICheckbox.js +15 -8
  51. package/Root/Frameworks/UIKit/UICollectionView.js +2 -2
  52. package/Root/Frameworks/UIKit/UIDisplayServer.js +51 -10
  53. package/Root/Frameworks/UIKit/UIHTMLTextTypesetter.js +2 -2
  54. package/Root/Frameworks/UIKit/UILayer.js +3 -0
  55. package/Root/Frameworks/UIKit/UIListView.js +10 -6
  56. package/Root/Frameworks/UIKit/UIMenuView.js +77 -18
  57. package/Root/Frameworks/UIKit/UINavigationBar.js +45 -22
  58. package/Root/Frameworks/UIKit/UIScrollView.js +26 -6
  59. package/Root/Frameworks/UIKit/UISlider.js +1 -1
  60. package/Root/Frameworks/UIKit/UITextField.js +8 -1
  61. package/Root/Frameworks/UIKit/UIView.js +11 -0
  62. package/Root/Frameworks/UIKitTesting/Info.yaml +1 -1
  63. package/package.json +1 -1
@@ -39,6 +39,7 @@ JSClass("UIDisplayServer", JSObject, {
39
39
  this.layerAnimationQueue = {};
40
40
  this._scheduleQueue = [];
41
41
  this._scheduled = [];
42
+ this._completedAnimations = [];
42
43
  },
43
44
 
44
45
  // -------------------------------------------------------------------------
@@ -100,7 +101,7 @@ JSClass("UIDisplayServer", JSObject, {
100
101
  this._scheduled = this._scheduleQueue;
101
102
  this._scheduleQueue = [];
102
103
  this._isUpdating = true;
103
- var completedAnimations = this._updateAnimations(t);
104
+ this._updateAnimations(t);
104
105
  this._flushLayerLayoutQueue();
105
106
  this._flushLayerDisplayQueue();
106
107
  this._flushLayerRepositionQueue();
@@ -110,9 +111,7 @@ JSClass("UIDisplayServer", JSObject, {
110
111
  this._isUpdating = false;
111
112
 
112
113
  // Call any animation callbacks
113
- for (var i = 0, l = completedAnimations.length; i < l; ++i){
114
- completedAnimations[i].completionFunction(completedAnimations[i]);
115
- }
114
+ this._flushCompletedAnimations();
116
115
 
117
116
  // Call any window insert/remove callbacks
118
117
  var window;
@@ -228,8 +227,22 @@ JSClass("UIDisplayServer", JSObject, {
228
227
  if (this.layerDisplayQueue.remove(layer)){
229
228
  layer._needsDisplay = true;
230
229
  }
230
+ var key;
231
+ var animation;
232
+ var completedAnimationKeys;
233
+ var i, l;
231
234
  this.layerRepositionQueue.remove(layer);
232
235
  if (layer.objectID in this.layerAnimationQueue){
236
+ completedAnimationKeys = [];
237
+ for (key in layer.animationsByKey){
238
+ animation = layer.animationsByKey[key];
239
+ this.completeAnimation(animation);
240
+ completedAnimationKeys.push(key);
241
+ }
242
+ for (i = 0, l = completedAnimationKeys.length; i < l; ++i){
243
+ key = completedAnimationKeys[i];
244
+ layer.removeAnimationForKey(key);
245
+ }
233
246
  delete this.layerAnimationQueue[layer.objectID];
234
247
  --this._animationCount;
235
248
  }
@@ -246,24 +259,53 @@ JSClass("UIDisplayServer", JSObject, {
246
259
  this.setUpdateNeeded();
247
260
  },
248
261
 
262
+ _completedAnimations: null,
263
+
264
+ completeAnimation: function(animation){
265
+ this._completedAnimations.push(animation);
266
+ },
267
+
268
+ _flushCompletedAnimations: function(){
269
+ var i, l;
270
+ var animation;
271
+ for (i = 0, l = this._completedAnimations.length; i < l; ++i){
272
+ animation = this._completedAnimations[i];
273
+ if (animation.completionFunction){
274
+ animation.completionFunction(animation);
275
+ }
276
+ }
277
+ this._completedAnimations = [];
278
+ },
279
+
249
280
  _updateAnimations: function(t){
250
281
  t /= this._animationScale;
251
282
  var animation;
252
- var completedAnimations = [];
253
283
  var id, key;
254
284
  var layer;
285
+ var completedAnimationKeys;
286
+ var i, l;
287
+ var parts;
255
288
  for (id in this.layerAnimationQueue){
256
289
  layer = this.layerAnimationQueue[id];
290
+ completedAnimationKeys = [];
257
291
  for (key in layer.animationsByKey){
258
292
  animation = layer.animationsByKey[key];
259
293
  animation.updateForTime(t);
260
294
  if (this.reducedMotionEnabled || animation.isComplete){
261
- layer.removeAnimationForKey(key);
262
- if (animation.completionFunction){
263
- completedAnimations.push(animation);
295
+ completedAnimationKeys.push(key);
296
+ }else{
297
+ parts = key.split('.');
298
+ if (parts[0] in layer.presentation){
299
+ this.layerDidChangeProperty(layer, key);
264
300
  }
265
301
  }
266
- var parts = key.split('.');
302
+ }
303
+ for (i = 0, l = completedAnimationKeys.length; i < l; ++i){
304
+ key = completedAnimationKeys[i];
305
+ animation = layer.animationsByKey[key];
306
+ layer.removeAnimationForKey(key);
307
+ this.completeAnimation(animation);
308
+ parts = key.split('.');
267
309
  if (parts[0] in layer.presentation){
268
310
  this.layerDidChangeProperty(layer, key);
269
311
  }
@@ -273,7 +315,6 @@ JSClass("UIDisplayServer", JSObject, {
273
315
  --this._animationCount;
274
316
  }
275
317
  }
276
- return completedAnimations;
277
318
  },
278
319
 
279
320
  // -------------------------------------------------------------------------
@@ -304,8 +304,8 @@ JSClass("UIHTMLTextTypesetter", JSTextTypesetter, {
304
304
  // word wrapping
305
305
  iterator.decrement();
306
306
  var characterBreakLocation = iterator.range.location;
307
- // back up to a word boundary
308
- while (iterator.index > range.location && !iterator.isWordBoundary){
307
+ // back up to a line break opportunity
308
+ while (iterator.index > range.location && !iterator.isLineBreakOpportunity){
309
309
  iterator.decrement();
310
310
  }
311
311
  if (iterator.range.location <= range.location){
@@ -608,6 +608,9 @@ JSClass("UILayer", JSObject, {
608
608
  },
609
609
 
610
610
  removeAnimationForKey: function(key){
611
+ if (!(key in this.animationsByKey)){
612
+ return;
613
+ }
611
614
  --this.animationCount;
612
615
  if (this.animationCount === 0){
613
616
  // If we're all done with animations, reset our presentation to be identical to our model
@@ -355,6 +355,7 @@ JSClass("UIListView", UIScrollView, {
355
355
  var y;
356
356
  var diff;
357
357
  var height;
358
+ var newHeight;
358
359
  var item;
359
360
  var y0 = firstVisibleItem.view.position.y - firstVisibleItem.view.anchorPoint.y * firstVisibleItem.view.bounds.size.height;
360
361
 
@@ -372,9 +373,10 @@ JSClass("UIListView", UIScrollView, {
372
373
  cell = item.view;
373
374
  height = cell.bounds.size.height;
374
375
  y = cell.position.y - cell.anchorPoint.y * height;
376
+ newHeight = this._heightForCellAtIndexPath(indexPath);
375
377
  this._enqueueReusableCell(cell);
376
- cell = this._createCellAtIndexPath(indexPath, JSRect(0, y, cell.bounds.size.width, height));
377
- diff = cell.bounds.size.height - height;
378
+ cell = this._createCellAtIndexPath(indexPath, JSRect(0, y, cell.bounds.size.width, newHeight));
379
+ diff = newHeight - height;
378
380
  if (cell !== item.view){
379
381
  this._cellsContainerView.insertSubviewBelowSibling(cell, item.view);
380
382
  item.view.removeFromSuperview();
@@ -382,6 +384,7 @@ JSClass("UIListView", UIScrollView, {
382
384
  }
383
385
  if (diff !== 0){
384
386
  visibleSizeChanged = true;
387
+ contentSize.height += diff;
385
388
  }
386
389
  }
387
390
  }
@@ -397,6 +400,7 @@ JSClass("UIListView", UIScrollView, {
397
400
  }else{
398
401
  this.contentSize = contentSize;
399
402
  this.contentOffset = contentOffset;
403
+ this._layoutVisibleItems(this._visibleItems, y0);
400
404
  }
401
405
 
402
406
  },
@@ -489,7 +493,7 @@ JSClass("UIListView", UIScrollView, {
489
493
  _approximateHeightForSection: function(section, stopRow){
490
494
  var height = this._approximateYForSectionFooter(section);
491
495
  if (this.delegate && this.delegate.heightForListViewFooterInSection && !this.delegate.estimatedHeightForListViewFooters){
492
- height = this.delegate.heightForListViewFooterInSection(section);
496
+ height += this.delegate.heightForListViewFooterInSection(this, section);
493
497
  }else{
494
498
  height += this._approximateFooterHeight;
495
499
  }
@@ -1635,7 +1639,7 @@ JSClass("UIListView", UIScrollView, {
1635
1639
  _heightForFooterInSection: function(section){
1636
1640
  var height = this._approximateFooterHeight;
1637
1641
  if (this.delegate.heightForListViewFooterInSection){
1638
- height = this.delegate.heightForListViewFooterInSection(section);
1642
+ height = this.delegate.heightForListViewFooterInSection(this, section);
1639
1643
  }
1640
1644
  return height;
1641
1645
  },
@@ -2347,7 +2351,7 @@ JSClass("UIListView", UIScrollView, {
2347
2351
  return;
2348
2352
  }
2349
2353
  this._touch = {
2350
- location0: touches[0].locationInView(this),
2354
+ location0: touches[0].locationInWindow,
2351
2355
  cell: null,
2352
2356
  timer: JSTimer.scheduledTimerWithInterval(0.05, function(){
2353
2357
  this._touch.timer = null;
@@ -2359,7 +2363,7 @@ JSClass("UIListView", UIScrollView, {
2359
2363
  touchesMoved: function(touches, event){
2360
2364
  UIListView.$super.touchesMoved.call(this, touches, event);
2361
2365
  if (this._touch !== null){
2362
- var location = touches[0].locationInView(this);
2366
+ var location = touches[0].locationInWindow;
2363
2367
  var diff = location.subtracting(this._touch.location0);
2364
2368
  if ((diff.x * diff.x + diff.y * diff.y) > 2){
2365
2369
  this._cancelTouchSelection();
@@ -309,20 +309,6 @@ JSClass("UIMenuWindow", UIWindow, {
309
309
  this._adjustHighlightForLocation(this._lastMoveLocation);
310
310
  },
311
311
 
312
- mouseDragged: function(event){
313
- if (this._isClosing){
314
- return;
315
- }
316
- var location = event.locationInView(this);
317
- this._lastMoveLocation = event.locationInView(this);
318
- this._adjustHighlightForLocation(this._lastMoveLocation);
319
- if (!this.containsPoint(location)){
320
- if (this._menu.supermenu !== null && this._menu.supermenu.stylerProperties.window){
321
- this._menu.supermenu.stylerProperties.window.mouseDragged(event);
322
- }
323
- }
324
- },
325
-
326
312
  mouseExited: function(event){
327
313
  if (this._isClosing){
328
314
  return;
@@ -350,6 +336,37 @@ JSClass("UIMenuWindow", UIWindow, {
350
336
 
351
337
  _itemDownTimestamp: UIEvent.minimumTimestamp,
352
338
 
339
+ mouseDown: function(event){
340
+ if (this._isClosing){
341
+ return;
342
+ }
343
+ var location = event.locationInView(this);
344
+ if (!this.containsPoint(location)){
345
+ if (this._menu.supermenu && this._menu.supermenu.stylerProperties.window){
346
+ this._menu.supermenu.stylerProperties.window.mouseDown(event);
347
+ }else{
348
+ this.closeAll(true);
349
+ }
350
+ }else{
351
+ this._lastMoveLocation = event.locationInView(this);
352
+ this._adjustHighlightForLocation(this._lastMoveLocation);
353
+ }
354
+ },
355
+
356
+ mouseDragged: function(event){
357
+ if (this._isClosing){
358
+ return;
359
+ }
360
+ var location = event.locationInView(this);
361
+ this._lastMoveLocation = event.locationInView(this);
362
+ this._adjustHighlightForLocation(this._lastMoveLocation);
363
+ if (!this.containsPoint(location)){
364
+ if (this._menu.supermenu !== null && this._menu.supermenu.stylerProperties.window){
365
+ this._menu.supermenu.stylerProperties.window.mouseDragged(event);
366
+ }
367
+ }
368
+ },
369
+
353
370
  mouseUp: function(event){
354
371
  if (event.timestamp - this._itemDownTimestamp < 0.2){
355
372
  return;
@@ -369,23 +386,65 @@ JSClass("UIMenuWindow", UIWindow, {
369
386
  }
370
387
  },
371
388
 
372
- mouseDown: function(event){
389
+ // -----------------------------------------------------------------------
390
+ // MARK: - Touch Events
391
+
392
+ touchesBegan: function(touches, event){
373
393
  if (this._isClosing){
374
394
  return;
375
395
  }
376
- var location = event.locationInView(this);
396
+ if (touches.length > 1){
397
+ return;
398
+ }
399
+ var location = touches[0].locationInView(this);
377
400
  if (!this.containsPoint(location)){
378
401
  if (this._menu.supermenu && this._menu.supermenu.stylerProperties.window){
379
- this._menu.supermenu.stylerProperties.window.mouseDown(event);
402
+ this._menu.supermenu.stylerProperties.window.touchesBegan(touches, event);
380
403
  }else{
381
404
  this.closeAll(true);
382
405
  }
383
406
  }else{
384
- this._lastMoveLocation = event.locationInView(this);
407
+ this._lastMoveLocation = location;
385
408
  this._adjustHighlightForLocation(this._lastMoveLocation);
386
409
  }
387
410
  },
388
411
 
412
+ touchesMoved: function(touches, event){
413
+ if (this._isClosing){
414
+ return;
415
+ }
416
+ var location = touches[0].locationInView(this);
417
+ this._lastMoveLocation = location;
418
+ this._adjustHighlightForLocation(this._lastMoveLocation);
419
+ if (!this.containsPoint(location)){
420
+ if (this._menu.supermenu !== null && this._menu.supermenu.stylerProperties.window){
421
+ this._menu.supermenu.stylerProperties.window.touchesMoved(touches, event);
422
+ }
423
+ }
424
+ },
425
+
426
+ touchesEnded: function(touches, event){
427
+ if (event.timestamp - this._itemDownTimestamp < 0.2){
428
+ return;
429
+ }
430
+ if (this._isClosing){
431
+ return;
432
+ }
433
+ var location = touches[0].locationInView(this);
434
+ if (this.containsPoint(location)){
435
+ this._performActionForHighlightedItem();
436
+ }else{
437
+ if (this._menu.supermenu && this._menu.supermenu.stylerProperties.window){
438
+ this._menu.supermenu.stylerProperties.window.touchesEnded(touches, event);
439
+ }else{
440
+ this.closeAll(true);
441
+ }
442
+ }
443
+ },
444
+
445
+ touchesCanceled: function(touches, event){
446
+ },
447
+
389
448
  // -----------------------------------------------------------------------
390
449
  // MARK: - Key Events
391
450
 
@@ -428,6 +428,8 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
428
428
  navigationBar.maskedBorders = UIView.Sides.maxY;
429
429
 
430
430
  var props = navigationBar.stylerProperties;
431
+ props.isAnimating = false;
432
+ props.needsUpdate = false;
431
433
  props.titleLabel = this.createTitleLabel();
432
434
  props.customView = null;
433
435
  navigationBar.addSubview(props.titleLabel);
@@ -468,6 +470,8 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
468
470
  var removingRightBarItemViews = props.rightBarItemViews;
469
471
  var removingTitleLabel = props.titleLabel;
470
472
  var removingCustomView = props.customView;
473
+ var removingCustomViewTransform = removingCustomView ? removingCustomView.transform : JSAffineTransform.Identity;
474
+ var customViewTransform = JSAffineTransform.Identity;
471
475
  var backToTitleScale = this.titleFont.displayLineHeight / this.itemFont.displayLineHeight;
472
476
  props.titleLabel = this.createTitleLabel();
473
477
  navigationBar.addSubview(props.titleLabel);
@@ -488,15 +492,16 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
488
492
  props.titleLabel.alpha = 0;
489
493
  props.titleLabel.transform = JSAffineTransform.Translated(navigationBar.bounds.size.width, 0);
490
494
  if (props.customView){
495
+ customViewTransform = props.customView.transform;
491
496
  props.customView.alpha = 0;
492
- props.customView.transform = JSAffineTransform.Translated(navigationBar.bounds.size.width, 0);
497
+ props.customView.transform = JSAffineTransform.Translated(navigationBar.bounds.size.width + customViewTransform.tx, customViewTransform.ty);
493
498
  }
494
499
  props.backBarItemView.alpha = 0;
495
500
  var backTitleFrame = props.backBarItemView.titleLabel.convertRectToView(props.backBarItemView.titleLabel.bounds, props.backBarItemView.superview);
496
501
  if (removingCustomView){
497
- props.backBarItemView.titleLabel.transform = JSAffineTransform.Translated(Math.max(0, removingCustomView.frame.origin.x - backTitleFrame.origin.x), 0).scaledBy(backToTitleScale);
502
+ props.backBarItemView.titleLabel.transform = JSAffineTransform.Translated(Math.max(0, removingCustomView.untransformedFrame.origin.x - backTitleFrame.origin.x), 0).scaledBy(backToTitleScale);
498
503
  }else{
499
- props.backBarItemView.titleLabel.transform = JSAffineTransform.Translated(Math.max(0, removingTitleLabel.frame.origin.x - backTitleFrame.origin.x), 0).scaledBy(backToTitleScale);
504
+ props.backBarItemView.titleLabel.transform = JSAffineTransform.Translated(Math.max(0, removingTitleLabel.untransformedFrame.origin.x - backTitleFrame.origin.x), 0).scaledBy(backToTitleScale);
500
505
  }
501
506
  animator.addAnimations(function(){
502
507
  var i, l;
@@ -514,20 +519,20 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
514
519
  }
515
520
  removingBackBarItemView.alpha = 0;
516
521
  removingTitleLabel.alpha = 0;
517
- removingTitleLabel.transform = JSAffineTransform.Translated(Math.min(0, backTitleFrame.origin.x - removingTitleLabel.frame.origin.x), 0).scaledBy(1 / backToTitleScale);
522
+ removingTitleLabel.transform = JSAffineTransform.Translated(Math.min(0, backTitleFrame.origin.x - removingTitleLabel.untransformedFrame.origin.x), 0).scaledBy(1 / backToTitleScale);
518
523
  if (removingCustomView){
519
524
  removingCustomView.alpha = 0;
520
- removingCustomView.transform = JSAffineTransform.Translated(Math.min(0, backTitleFrame.origin.x - removingCustomView.frame.origin.x), 0).scaledBy(1 / backToTitleScale);
525
+ removingCustomView.transform = JSAffineTransform.Translated(Math.min(0, backTitleFrame.origin.x - removingCustomView.untransformedFrame.origin.x) + removingCustomViewTransform.tx, removingCustomViewTransform.ty).scaledBy(1 / backToTitleScale);
521
526
  }
522
527
  props.titleLabel.alpha = 1;
523
528
  props.titleLabel.transform = JSAffineTransform.Identity;
524
529
  if (props.customView){
525
530
  props.customView.alpha = 1;
526
- props.customView.transform = JSAffineTransform.Identity;
531
+ props.customView.transform = customViewTransform;
527
532
  }
528
533
  props.backBarItemView.alpha = 1;
529
534
  props.backBarItemView.titleLabel.transform = JSAffineTransform.Identity;
530
- });
535
+ }, this);
531
536
  animator.addCompletion(function(){
532
537
  var i, l;
533
538
  for (i = 0, l = removingLeftBarItemViews.length; i < l; ++i){
@@ -540,9 +545,14 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
540
545
  removingBackBarItemView.removeFromSuperview();
541
546
  if (removingCustomView !== null){
542
547
  removingCustomView.removeFromSuperview();
543
- removingCustomView.transform = JSAffineTransform.Identity;
548
+ removingCustomView.transform = removingCustomViewTransform;
544
549
  }
545
- });
550
+ props.isAnimating = false;
551
+ if (props.needsUpdate){
552
+ this.updateBar(navigationBar);
553
+ }
554
+ }, this);
555
+ props.isAnimating = true;
546
556
  },
547
557
 
548
558
  popToItem: function(navigationBar, item, animator){
@@ -553,6 +563,8 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
553
563
  var removingRightBarItemViews = props.rightBarItemViews;
554
564
  var removingTitleLabel = props.titleLabel;
555
565
  var removingCustomView = props.customView;
566
+ var removingCustomViewTransform = removingCustomView ? removingCustomView.transform : JSAffineTransform.Identity;
567
+ var customViewTransform = JSAffineTransform.Identity;
556
568
  var backToTitleScale = this.titleFont.displayLineHeight / this.itemFont.displayLineHeight;
557
569
  props.titleLabel = this.createTitleLabel();
558
570
  navigationBar.addSubview(props.titleLabel);
@@ -574,10 +586,11 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
574
586
  props.backBarItemView.alpha = 0;
575
587
  var backTitleFrame = removingBackBarItemView.titleLabel.convertRectToView(removingBackBarItemView.titleLabel.bounds, props.backBarItemView.superview);
576
588
  if (props.customView){
577
- props.customView.transform = JSAffineTransform.Translated(Math.min(0, backTitleFrame.origin.x - props.customView.frame.origin.x), 0).scaledBy(1 / backToTitleScale);
589
+ customViewTransform = props.customView.transform;
590
+ props.customView.transform = JSAffineTransform.Translated(Math.min(0, backTitleFrame.origin.x - props.customView.untransformedFrame.origin.x) + customViewTransform.tx, customViewTransform.ty).scaledBy(1 / backToTitleScale);
578
591
  props.customView.alpha = 0;
579
592
  }else{
580
- props.titleLabel.transform = JSAffineTransform.Translated(Math.min(0, backTitleFrame.origin.x - props.titleLabel.frame.origin.x), 0).scaledBy(1 / backToTitleScale);
593
+ props.titleLabel.transform = JSAffineTransform.Translated(Math.min(0, backTitleFrame.origin.x - props.titleLabel.untransformedFrame.origin.x), 0).scaledBy(1 / backToTitleScale);
581
594
  }
582
595
  animator.addAnimations(function(){
583
596
  var i, l;
@@ -598,7 +611,7 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
598
611
  removingTitleLabel.transform = JSAffineTransform.Translated(navigationBar.bounds.size.width, 0);
599
612
  if (removingCustomView){
600
613
  removingCustomView.alpha = 0;
601
- removingCustomView.transform = JSAffineTransform.Translated(navigationBar.bounds.size.width, 0);
614
+ removingCustomView.transform = JSAffineTransform.Translated(navigationBar.bounds.size.width + removingCustomViewTransform.tx, removingCustomViewTransform.ty);
602
615
  }
603
616
  props.titleLabel.alpha = 1;
604
617
  props.titleLabel.transform = JSAffineTransform.Identity;
@@ -606,9 +619,9 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
606
619
  props.backBarItemView.titleLabel.transform = JSAffineTransform.Identity;
607
620
  if (props.customView){
608
621
  props.customView.alpha = 1;
609
- props.customView.transform = JSAffineTransform.Identity;
622
+ props.customView.transform = customViewTransform;
610
623
  }
611
- });
624
+ }, this);
612
625
  animator.addCompletion(function(){
613
626
  var i, l;
614
627
  for (i = 0, l = removingLeftBarItemViews.length; i < l; ++i){
@@ -621,14 +634,24 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
621
634
  removingBackBarItemView.removeFromSuperview();
622
635
  if (removingCustomView !== null){
623
636
  removingCustomView.removeFromSuperview();
624
- removingCustomView.transform = JSAffineTransform.Identity;
637
+ removingCustomView.transform = removingCustomViewTransform;
638
+ }
639
+ props.isAnimating = false;
640
+ if (props.needsUpdate){
641
+ this.updateBar(navigationBar);
625
642
  }
626
- });
643
+ }, this);
644
+ props.isAnimating = true;
627
645
  },
628
646
 
629
647
  updateBar: function(navigationBar){
630
648
  var item = navigationBar.topItem;
631
649
  var props = navigationBar.stylerProperties;
650
+ if (props.isAnimating){
651
+ props.needsUpdate = true;
652
+ return;
653
+ }
654
+ props.needsUpdate = false;
632
655
 
633
656
  var i, l;
634
657
  for (i = 0, l = props.leftBarItemViews.length; i < l; ++i){
@@ -708,7 +731,7 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
708
731
  var barItemView = props.backBarItemView;
709
732
  var titleTextAlignment = item ? item.titleTextAlignment || this.titleTextAlignment : this.titleTextAlignment;
710
733
  barItemView.sizeToFitSize(JSSize(xRight - xLeft, itemHeight));
711
- barItemView.frame = JSRect(JSPoint(xLeft, y + (itemHeight - barItemView.bounds.size.height) / 2), barItemView.bounds.size);
734
+ barItemView.untransformedFrame = JSRect(JSPoint(xLeft, y + (itemHeight - barItemView.bounds.size.height) / 2), barItemView.bounds.size);
712
735
  if (!barItemView.hidden){
713
736
  xLeft += barItemView.bounds.size.width;
714
737
  }else if (props.leftBarItemViews.length === 0 && titleTextAlignment === JSTextAlignment.left && this.titleInsets !== null){
@@ -717,14 +740,14 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
717
740
  for (i = 0, l = props.leftBarItemViews.length; i < l; ++i){
718
741
  barItemView = props.leftBarItemViews[i];
719
742
  barItemView.sizeToFitSize(JSSize(xRight - xLeft, itemHeight));
720
- barItemView.frame = JSRect(JSPoint(xLeft, y + (itemHeight - barItemView.bounds.size.height) / 2), barItemView.bounds.size);
743
+ barItemView.untransformedFrame = JSRect(JSPoint(xLeft, y + (itemHeight - barItemView.bounds.size.height) / 2), barItemView.bounds.size);
721
744
  xLeft += barItemView.bounds.size.width;
722
745
  }
723
746
  for (i = props.rightBarItemViews.length - 1; i >= 0; --i){
724
747
  barItemView = props.rightBarItemViews[i];
725
748
  barItemView.sizeToFitSize(JSSize(xRight - xLeft, itemHeight));
726
749
  xRight -= barItemView.bounds.size.width;
727
- barItemView.frame = JSRect(JSPoint(xRight, y + (itemHeight - barItemView.bounds.size.height) / 2), barItemView.bounds.size);
750
+ barItemView.untransformedFrame = JSRect(JSPoint(xRight, y + (itemHeight - barItemView.bounds.size.height) / 2), barItemView.bounds.size);
728
751
  barItemView.hidden = xRight < xLeft;
729
752
  }
730
753
 
@@ -746,11 +769,11 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
746
769
  var centeredX = (size.width - viewSize.width) / 2;
747
770
  var centeredY = (size.height - viewSize.height) / 2;
748
771
  if (titleTextAlignment === JSTextAlignment.center){
749
- titleView.frame = JSRect(JSPoint(Math.min(Math.max(minX, centeredX), maxX), centeredY), viewSize);
772
+ titleView.untransformedFrame = JSRect(JSPoint(Math.min(Math.max(minX, centeredX), maxX), centeredY), viewSize);
750
773
  }else if (titleTextAlignment === JSTextAlignment.right){
751
- titleView.frame = JSRect(JSPoint(maxX - viewSize.width, centeredY), viewSize);
774
+ titleView.untransformedFrame = JSRect(JSPoint(maxX - viewSize.width, centeredY), viewSize);
752
775
  }else{
753
- titleView.frame = JSRect(JSPoint(minX, centeredY), viewSize);
776
+ titleView.untransformedFrame = JSRect(JSPoint(minX, centeredY), viewSize);
754
777
  }
755
778
  }else{
756
779
  props.titleLabel.hidden = true;
@@ -281,16 +281,12 @@ JSClass('UIScrollView', UIView, {
281
281
  offset = JSPoint(offset);
282
282
  offset.x = Math.round(offset.x);
283
283
  offset.y = Math.round(offset.y);
284
- if (!this.scrollsHorizontally){
285
- offset.x = this._contentOffset.x;
286
- }else if (offset.x < this._minContentOffset.x){
284
+ if (offset.x < this._minContentOffset.x){
287
285
  offset.x = this._minContentOffset.x;
288
286
  }else if (offset.x > this._maxContentOffset.x){
289
287
  offset.x = this._maxContentOffset.x;
290
288
  }
291
- if (!this.scrollsVertically){
292
- offset.y = this._contentOffset.y;
293
- }else if (offset.y < this._minContentOffset.y){
289
+ if (offset.y < this._minContentOffset.y){
294
290
  offset.y = this._minContentOffset.y;
295
291
  }else if (offset.y > this._maxContentOffset.y){
296
292
  offset.y = this._maxContentOffset.y;
@@ -515,6 +511,12 @@ JSClass('UIScrollView', UIView, {
515
511
  }else{
516
512
  var d = JSPoint(event.scrollingDelta);
517
513
  var abs = JSPoint(Math.abs(d.x), Math.abs(d.y));
514
+ if (!this._scrollsVertically){
515
+ d.y = 0;
516
+ }
517
+ if (!this._scrollsHorizontally){
518
+ d.x = 0;
519
+ }
518
520
  if (abs.x > 2 * abs.y){
519
521
  d.y = 0;
520
522
  }else if (abs.y > 2 * abs.x){
@@ -581,10 +583,16 @@ JSClass('UIScrollView', UIView, {
581
583
  },
582
584
 
583
585
  touchesBegan: function(touches, event){
586
+ if (!this._scrollsVertically && !this._scrollsHorizontally){
587
+ return UIScrollView.$super.touchesBegan.call(this, touches, event);
588
+ }
584
589
  this._beginTrackingTouches(touches, event);
585
590
  },
586
591
 
587
592
  touchesMoved: function(touches, event){
593
+ if (!this._scrollsVertically && !this._scrollsHorizontally){
594
+ return UIScrollView.$super.touchesMoved.call(this, touches, event);
595
+ }
588
596
  if (this._touchTracking === null){
589
597
  this._beginTrackingTouches(touches, event);
590
598
  }
@@ -594,6 +602,12 @@ JSClass('UIScrollView', UIView, {
594
602
  }
595
603
  var location = touch.locationInView(this);
596
604
  var delta = location.subtracting(this._touchTracking.startingLocation);
605
+ if (!this._scrollsVertically){
606
+ delta.y = 0;
607
+ }
608
+ if (!this._scrollsHorizontally){
609
+ delta.x = 0;
610
+ }
597
611
  var offset = this._touchTracking.contentOffset.subtracting(delta);
598
612
  delta = location.subtracting(this._touchTracking.location);
599
613
  var dt = event.timestamp - this._touchTracking.timestamp;
@@ -606,6 +620,9 @@ JSClass('UIScrollView', UIView, {
606
620
  },
607
621
 
608
622
  touchesEnded: function(touches, event){
623
+ if (!this._scrollsVertically && !this._scrollsHorizontally){
624
+ return UIScrollView.$super.touchesEnded.call(this, touches, event);
625
+ }
609
626
  var dt = event.timestamp - this._touchTracking.timestamp;
610
627
  if (dt < 0.05){
611
628
  this._beginCoasting(this._touchTracking.velocity);
@@ -614,6 +631,9 @@ JSClass('UIScrollView', UIView, {
614
631
  },
615
632
 
616
633
  touchesCanceled: function(touches, event){
634
+ if (!this._scrollsVertically && !this._scrollsHorizontally){
635
+ return UIScrollView.$super.touchesCanceled.call(this, touches, event);
636
+ }
617
637
  this._endTrackingTouches();
618
638
  },
619
639
 
@@ -584,7 +584,7 @@ JSClass("UISliderColorStyler", UISliderLayerBasedStyler, {
584
584
  },
585
585
 
586
586
  initWithSpec: function(spec){
587
- UISliderColorStyler.$super.initWithSpec.call(this);
587
+ UISliderColorStyler.$super.initWithSpec.call(this, spec);
588
588
  this._commonColorStylerInit();
589
589
  if (spec.containsKey("gradient")){
590
590
  this.gradient = spec.valueForKey("gradient", JSGradient);
@@ -713,7 +713,14 @@ JSClass("UITextField", UIControl, {
713
713
  size = JSSize(this._placeholderLabel.bounds.size);
714
714
  }else{
715
715
  if (this._multiline){
716
- this._textLayer.sizeToFitSize(maxSize);
716
+ var maxTextSize = JSSize(maxSize);
717
+ if (maxTextSize.width < Number.MAX_VALUE){
718
+ maxTextSize.width -= this._textInsets.width;
719
+ }
720
+ if (maxTextSize.height < Number.MAX_VALUE){
721
+ maxTextSize.height -= this._textInsets.height;
722
+ }
723
+ this._textLayer.sizeToFitSize(maxTextSize);
717
724
  }
718
725
  this._textLayer.layoutIfNeeded();
719
726
  size = JSSize(this._textLayer.bounds.size);
@@ -323,6 +323,17 @@ JSClass('UIView', UIResponder, {
323
323
  return null;
324
324
  },
325
325
 
326
+ isDescendantOfView: function(view){
327
+ if (view === null || view === undefined){
328
+ return false;
329
+ }
330
+ var superview = this.superview;
331
+ while (superview !== null && superview !== view){
332
+ superview = superview.superview;
333
+ }
334
+ return superview !== null && superview === view;
335
+ },
336
+
326
337
  // -------------------------------------------------------------------------
327
338
  // MARK: - Window
328
339
 
@@ -1,6 +1,6 @@
1
1
  JSBundleType: framework
2
2
  JSBundleIdentifier: io.breakside.JSKit.UIKitTesting
3
- JSBundleVersion: 2022.26.1
3
+ JSBundleVersion: 2022.32.0
4
4
  JSDevelopmentLanguage: en
5
5
  JSCopyright: Copyright © 2020 Breakside Inc.
6
6
  JSLicenseNotice: |