leafer-ui 1.3.3 → 1.4.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.
@@ -3821,10 +3821,10 @@ function autoLayoutType(defaultValue) {
3821
3821
  return decorateLeafAttr(defaultValue, (key) => attr({
3822
3822
  set(value) {
3823
3823
  if (this.__setAttr(key, value)) {
3824
- this.__layout.matrixChanged || this.__layout.matrixChange();
3825
3824
  this.__hasAutoLayout = !!(this.origin || this.around || this.flow);
3826
3825
  if (!this.__local)
3827
3826
  this.__layout.createLocal();
3827
+ doBoundsType(this);
3828
3828
  }
3829
3829
  }
3830
3830
  }));
@@ -4207,55 +4207,62 @@ const LeafHelper = {
4207
4207
  y += t.y;
4208
4208
  transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
4209
4209
  },
4210
- zoomOfWorld(t, origin, scaleX, scaleY, resize) {
4211
- L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
4210
+ zoomOfWorld(t, origin, scaleX, scaleY, resize, transition) {
4211
+ L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize, transition);
4212
4212
  },
4213
- zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
4214
- copy$7(matrix$1, t.__localMatrix);
4213
+ zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize, transition) {
4214
+ const o = t.__localMatrix;
4215
+ if (typeof scaleY !== 'number') {
4216
+ if (scaleY)
4217
+ transition = scaleY;
4218
+ scaleY = scaleX;
4219
+ }
4220
+ copy$7(matrix$1, o);
4215
4221
  scaleOfOuter$2(matrix$1, origin, scaleX, scaleY);
4216
4222
  if (t.origin || t.around) {
4217
- L.setTransform(t, matrix$1, resize);
4223
+ L.setTransform(t, matrix$1, resize, transition);
4218
4224
  }
4219
4225
  else {
4220
- moveByMatrix(t, matrix$1);
4221
- t.scaleResize(scaleX, scaleY, resize !== true);
4226
+ const x = t.x + matrix$1.e - o.e, y = t.y + matrix$1.f - o.f;
4227
+ if (transition && !resize)
4228
+ t.animate({ x, y, scaleX: t.scaleX * scaleX, scaleY: t.scaleY * scaleY }, transition);
4229
+ else
4230
+ t.x = x, t.y = y, t.scaleResize(scaleX, scaleY, resize !== true);
4222
4231
  }
4223
4232
  },
4224
- rotateOfWorld(t, origin, angle) {
4225
- L.rotateOfLocal(t, getTempLocal(t, origin), angle);
4233
+ rotateOfWorld(t, origin, angle, transition) {
4234
+ L.rotateOfLocal(t, getTempLocal(t, origin), angle, transition);
4226
4235
  },
4227
- rotateOfLocal(t, origin, angle) {
4228
- copy$7(matrix$1, t.__localMatrix);
4236
+ rotateOfLocal(t, origin, angle, transition) {
4237
+ const o = t.__localMatrix;
4238
+ copy$7(matrix$1, o);
4229
4239
  rotateOfOuter$2(matrix$1, origin, angle);
4230
- if (t.origin || t.around) {
4231
- L.setTransform(t, matrix$1);
4232
- }
4233
- else {
4234
- moveByMatrix(t, matrix$1);
4235
- t.rotation = MathHelper.formatRotation(t.rotation + angle);
4236
- }
4240
+ if (t.origin || t.around)
4241
+ L.setTransform(t, matrix$1, false, transition);
4242
+ else
4243
+ t.set({ x: t.x + matrix$1.e - o.e, y: t.y + matrix$1.f - o.f, rotation: MathHelper.formatRotation(t.rotation + angle) }, transition);
4237
4244
  },
4238
- skewOfWorld(t, origin, skewX, skewY, resize) {
4239
- L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
4245
+ skewOfWorld(t, origin, skewX, skewY, resize, transition) {
4246
+ L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize, transition);
4240
4247
  },
4241
- skewOfLocal(t, origin, skewX, skewY = 0, resize) {
4248
+ skewOfLocal(t, origin, skewX, skewY = 0, resize, transition) {
4242
4249
  copy$7(matrix$1, t.__localMatrix);
4243
4250
  skewOfOuter(matrix$1, origin, skewX, skewY);
4244
- L.setTransform(t, matrix$1, resize);
4251
+ L.setTransform(t, matrix$1, resize, transition);
4245
4252
  },
4246
- transformWorld(t, transform, resize) {
4253
+ transformWorld(t, transform, resize, transition) {
4247
4254
  copy$7(matrix$1, t.worldTransform);
4248
4255
  multiplyParent$2(matrix$1, transform);
4249
4256
  if (t.parent)
4250
4257
  divideParent(matrix$1, t.parent.worldTransform);
4251
- L.setTransform(t, matrix$1, resize);
4258
+ L.setTransform(t, matrix$1, resize, transition);
4252
4259
  },
4253
- transform(t, transform, resize) {
4260
+ transform(t, transform, resize, transition) {
4254
4261
  copy$7(matrix$1, t.localTransform);
4255
4262
  multiplyParent$2(matrix$1, transform);
4256
- L.setTransform(t, matrix$1, resize);
4263
+ L.setTransform(t, matrix$1, resize, transition);
4257
4264
  },
4258
- setTransform(t, transform, resize) {
4265
+ setTransform(t, transform, resize, transition) {
4259
4266
  const data = t.__, originPoint = data.origin && L.getInnerOrigin(t, data.origin);
4260
4267
  const layout = getLayout(transform, originPoint, data.around && L.getInnerOrigin(t, data.around));
4261
4268
  if (resize) {
@@ -4270,7 +4277,7 @@ const LeafHelper = {
4270
4277
  t.scaleResize(scaleX, scaleY, false);
4271
4278
  }
4272
4279
  else
4273
- t.set(layout);
4280
+ t.set(layout, transition);
4274
4281
  },
4275
4282
  getFlipTransform(t, axis) {
4276
4283
  const m = getMatrixData();
@@ -4307,11 +4314,6 @@ const LeafHelper = {
4307
4314
  };
4308
4315
  const L = LeafHelper;
4309
4316
  const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L;
4310
- function moveByMatrix(t, matrix) {
4311
- const { e, f } = t.__localMatrix;
4312
- t.x += matrix.e - e;
4313
- t.y += matrix.f - f;
4314
- }
4315
4317
  function getTempLocal(t, world) {
4316
4318
  t.__layout.update();
4317
4319
  return t.parent ? PointHelper.tempToInnerOf(world, t.parent.__world) : world;
@@ -5585,11 +5587,11 @@ let Leaf = class Leaf {
5585
5587
  const layer = this.leafer ? this.leafer.zoomLayer : this;
5586
5588
  return layer.getWorldPoint(page, relative, distance, change);
5587
5589
  }
5588
- setTransform(matrix, resize) {
5589
- setTransform(this, matrix, resize);
5590
+ setTransform(matrix, resize, transition) {
5591
+ setTransform(this, matrix, resize, transition);
5590
5592
  }
5591
- transform(matrix, resize) {
5592
- transform(this, matrix, resize);
5593
+ transform(matrix, resize, transition) {
5594
+ transform(this, matrix, resize, transition);
5593
5595
  }
5594
5596
  move(x, y, transition) {
5595
5597
  moveLocal(this, x, y, transition);
@@ -5597,32 +5599,32 @@ let Leaf = class Leaf {
5597
5599
  moveInner(x, y, transition) {
5598
5600
  moveWorld(this, x, y, true, transition);
5599
5601
  }
5600
- scaleOf(origin, scaleX, scaleY, resize) {
5601
- zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
5602
+ scaleOf(origin, scaleX, scaleY, resize, transition) {
5603
+ zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize, transition);
5602
5604
  }
5603
- rotateOf(origin, rotation) {
5604
- rotateOfLocal(this, getLocalOrigin(this, origin), rotation);
5605
+ rotateOf(origin, rotation, transition) {
5606
+ rotateOfLocal(this, getLocalOrigin(this, origin), rotation, transition);
5605
5607
  }
5606
- skewOf(origin, skewX, skewY, resize) {
5607
- skewOfLocal(this, getLocalOrigin(this, origin), skewX, skewY, resize);
5608
+ skewOf(origin, skewX, skewY, resize, transition) {
5609
+ skewOfLocal(this, getLocalOrigin(this, origin), skewX, skewY, resize, transition);
5608
5610
  }
5609
- transformWorld(worldTransform, resize) {
5610
- transformWorld(this, worldTransform, resize);
5611
+ transformWorld(worldTransform, resize, transition) {
5612
+ transformWorld(this, worldTransform, resize, transition);
5611
5613
  }
5612
5614
  moveWorld(x, y, transition) {
5613
5615
  moveWorld(this, x, y, false, transition);
5614
5616
  }
5615
- scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
5616
- zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
5617
+ scaleOfWorld(worldOrigin, scaleX, scaleY, resize, transition) {
5618
+ zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize, transition);
5617
5619
  }
5618
5620
  rotateOfWorld(worldOrigin, rotation) {
5619
5621
  rotateOfWorld(this, worldOrigin, rotation);
5620
5622
  }
5621
- skewOfWorld(worldOrigin, skewX, skewY, resize) {
5622
- skewOfWorld(this, worldOrigin, skewX, skewY, resize);
5623
+ skewOfWorld(worldOrigin, skewX, skewY, resize, transition) {
5624
+ skewOfWorld(this, worldOrigin, skewX, skewY, resize, transition);
5623
5625
  }
5624
- flip(axis) {
5625
- transform(this, getFlipTransform(this, axis));
5626
+ flip(axis, transition) {
5627
+ transform(this, getFlipTransform(this, axis), false, transition);
5626
5628
  }
5627
5629
  scaleResize(scaleX, scaleY = scaleX, _noResize) {
5628
5630
  this.scaleX *= scaleX;
@@ -6010,7 +6012,7 @@ class LeafLevelList {
6010
6012
  }
6011
6013
  }
6012
6014
 
6013
- const version = "1.3.3";
6015
+ const version = "1.4.0";
6014
6016
 
6015
6017
  const debug$5 = Debug.get('LeaferCanvas');
6016
6018
  class LeaferCanvas extends LeaferCanvasBase {
@@ -6130,7 +6132,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6130
6132
  }
6131
6133
  }
6132
6134
  else {
6133
- window.addEventListener('resize', () => {
6135
+ window.addEventListener('resize', this.windowListener = () => {
6134
6136
  const pixelRatio = Platform.devicePixelRatio;
6135
6137
  if (this.pixelRatio !== pixelRatio) {
6136
6138
  const { width, height } = this;
@@ -6159,11 +6161,9 @@ class LeaferCanvas extends LeaferCanvasBase {
6159
6161
  }
6160
6162
  stopAutoLayout() {
6161
6163
  this.autoLayout = false;
6162
- this.resizeListener = null;
6163
- if (this.resizeObserver) {
6164
+ if (this.resizeObserver)
6164
6165
  this.resizeObserver.disconnect();
6165
- this.resizeObserver = null;
6166
- }
6166
+ this.resizeListener = this.resizeObserver = null;
6167
6167
  }
6168
6168
  emitResize(size) {
6169
6169
  const oldSize = {};
@@ -6184,6 +6184,10 @@ class LeaferCanvas extends LeaferCanvasBase {
6184
6184
  destroy() {
6185
6185
  if (this.view) {
6186
6186
  this.stopAutoLayout();
6187
+ if (this.windowListener) {
6188
+ window.removeEventListener('resize', this.windowListener);
6189
+ this.windowListener = null;
6190
+ }
6187
6191
  if (!this.unreal) {
6188
6192
  const view = this.view;
6189
6193
  if (view.parentElement)
@@ -6210,7 +6214,10 @@ function useCanvas(_canvasType, _power) {
6210
6214
  canvas.height = height;
6211
6215
  return canvas;
6212
6216
  },
6213
- canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
6217
+ canvasToDataURL: (canvas, type, quality) => {
6218
+ const imageType = mineType(type), url = canvas.toDataURL(imageType, quality);
6219
+ return imageType === 'image/bmp' ? url.replace('image/png;', 'image/bmp;') : url;
6220
+ },
6214
6221
  canvasToBolb: (canvas, type, quality) => new Promise((resolve) => canvas.toBlob(resolve, mineType(type), quality)),
6215
6222
  canvasSaveAs: (canvas, filename, quality) => {
6216
6223
  const url = canvas.toDataURL(mineType(fileType(filename)), quality);
@@ -6255,7 +6262,7 @@ function useCanvas(_canvasType, _power) {
6255
6262
  Platform.name = 'web';
6256
6263
  Platform.isMobile = 'ontouchstart' in window;
6257
6264
  Platform.requestRender = function (render) { window.requestAnimationFrame(render); };
6258
- defineKey(Platform, 'devicePixelRatio', { get() { return Math.max(1, devicePixelRatio); } });
6265
+ defineKey(Platform, 'devicePixelRatio', { get() { return devicePixelRatio; } });
6259
6266
  const { userAgent } = navigator;
6260
6267
  if (userAgent.indexOf("Firefox") > -1) {
6261
6268
  Platform.conicGradientRotate90 = true;
@@ -9691,10 +9698,9 @@ class InteractionBase {
9691
9698
  }
9692
9699
  }
9693
9700
  pointerMoveReal(data) {
9694
- const { dragHover, dragDistance } = this.p;
9695
9701
  this.emit(PointerEvent$1.BEFORE_MOVE, data, this.defaultPath);
9696
9702
  if (this.downData) {
9697
- const canDrag = PointHelper.getDistance(this.downData, data) > dragDistance;
9703
+ const canDrag = PointHelper.getDistance(this.downData, data) > this.p.dragDistance;
9698
9704
  if (canDrag) {
9699
9705
  if (this.waitTap)
9700
9706
  this.pointerWaitCancel();
@@ -9706,9 +9712,8 @@ class InteractionBase {
9706
9712
  this.updateHoverData(data);
9707
9713
  this.checkPath(data);
9708
9714
  this.emit(PointerEvent$1.MOVE, data);
9709
- if (!(this.dragging && !dragHover))
9710
- this.pointerHover(data);
9711
- if (this.dragger.dragging) {
9715
+ this.pointerHover(data);
9716
+ if (this.dragging) {
9712
9717
  this.dragger.dragOverOrOut(data);
9713
9718
  this.dragger.dragEnterOrLeave(data);
9714
9719
  }
@@ -9789,7 +9794,8 @@ class InteractionBase {
9789
9794
  this.updateCursor();
9790
9795
  }
9791
9796
  pointerHover(data) {
9792
- if (this.canHover) {
9797
+ if (this.canHover && !(this.dragging && !this.p.dragHover)) {
9798
+ data.path || (data.path = new LeafList());
9793
9799
  this.pointerOverOrOut(data);
9794
9800
  this.pointerEnterOrLeave(data);
9795
9801
  }
@@ -10268,6 +10274,7 @@ class Interaction extends InteractionBase {
10268
10274
  'pointerdown': this.onPointerDown,
10269
10275
  'mousedown': this.onMouseDown,
10270
10276
  'touchstart': this.onTouchStart,
10277
+ 'pointerleave': this.onPointerLeave,
10271
10278
  'contextmenu': this.onContextMenu,
10272
10279
  'wheel': this.onWheel,
10273
10280
  'gesturestart': this.onGesturestart,
@@ -10350,11 +10357,15 @@ class Interaction extends InteractionBase {
10350
10357
  this.usePointer || (this.usePointer = true);
10351
10358
  this.pointerDown(PointerEventHelper.convert(e, this.getLocal(e)));
10352
10359
  }
10353
- onPointerMove(e) {
10360
+ onPointerMove(e, isLeave) {
10354
10361
  if (this.config.pointer.touch || this.useMultiTouch || this.preventWindowPointer(e))
10355
10362
  return;
10356
10363
  this.usePointer || (this.usePointer = true);
10357
- this.pointerMove(PointerEventHelper.convert(e, this.getLocal(e, true)));
10364
+ const data = PointerEventHelper.convert(e, this.getLocal(e, true));
10365
+ isLeave ? this.pointerHover(data) : this.pointerMove(data);
10366
+ }
10367
+ onPointerLeave(e) {
10368
+ this.onPointerMove(e, true);
10358
10369
  }
10359
10370
  onPointerUp(e) {
10360
10371
  if (this.downData)
@@ -11740,11 +11751,11 @@ const TextMode = 2;
11740
11751
  function layoutChar(drawData, style, width, _height) {
11741
11752
  const { rows } = drawData;
11742
11753
  const { textAlign, paraIndent, letterSpacing } = style;
11743
- let charX, addWordWidth, indentWidth, mode, wordChar;
11754
+ let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
11744
11755
  rows.forEach(row => {
11745
11756
  if (row.words) {
11746
- indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
11747
- addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
11757
+ indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
11758
+ addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && wordsLength > 1) ? (width - row.width - indentWidth) / (wordsLength - 1) : 0;
11748
11759
  mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
11749
11760
  if (row.isOverflow && !letterSpacing)
11750
11761
  row.textMode = true;
@@ -11756,7 +11767,7 @@ function layoutChar(drawData, style, width, _height) {
11756
11767
  row.x += indentWidth;
11757
11768
  charX = row.x;
11758
11769
  row.data = [];
11759
- row.words.forEach(word => {
11770
+ row.words.forEach((word, index) => {
11760
11771
  if (mode === WordMode) {
11761
11772
  wordChar = { char: '', x: charX };
11762
11773
  charX = toWordChar(word.data, charX, wordChar);
@@ -11766,7 +11777,7 @@ function layoutChar(drawData, style, width, _height) {
11766
11777
  else {
11767
11778
  charX = toChar(word.data, charX, row.data, row.isOverflow);
11768
11779
  }
11769
- if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
11780
+ if (addWordWidth && (!row.paraEnd || textAlign === 'both') && (index !== wordsLength - 1)) {
11770
11781
  charX += addWordWidth;
11771
11782
  row.width += addWordWidth;
11772
11783
  }
@@ -12023,3 +12034,4 @@ Object.assign(Creator, {
12023
12034
  useCanvas();
12024
12035
 
12025
12036
  export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent$1 as DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent$1 as PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
12037
+ //# sourceMappingURL=web.module.js.map