optimized Morph >> scrollIntoView()

snap7
jmoenig 2021-07-08 12:01:25 +02:00
rodzic 8a9888061e
commit 04bf915d12
3 zmienionych plików z 10 dodań i 7 usunięć

Wyświetl plik

@ -25,6 +25,7 @@
* gui: accelerated unified palette scrolling animation
* adjust scroll bars when refreshing the palette
* store: commented out saving the unified palette setting in the project xml during development
* morphic: optimized Morph >> scrollIntoView()
### 2021-07-07
* morphic, gui: tweaked perish() animation

Wyświetl plik

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Snap! 7 - dev - Build Your Own Blocks</title>
<link rel="icon" href="src/favicon.ico">
<script src="src/morphic.js?version=2021-07-07"></script>
<script src="src/morphic.js?version=2021-07-08"></script>
<script src="src/symbols.js?version=2021-03-03"></script>
<script src="src/widgets.js?version=2021-07-05"></script>
<script src="src/blocks.js?version=2021-07-05"></script>

Wyświetl plik

@ -1291,7 +1291,7 @@
/*jshint esversion: 6*/
var morphicVersion = '2021-July-07';
var morphicVersion = '2021-July-08';
var modules = {}; // keep track of additional loaded modules
var useBlurredShadows = true;
@ -3422,24 +3422,26 @@ Morph.prototype.keepWithin = function (aMorph) {
Morph.prototype.scrollIntoView = function () {
var leftOff, rightOff, topOff, bottomOff,
sf = this.parentThatIsA(ScrollFrameMorph);
sf = this.parentThatIsA(ScrollFrameMorph),
fb;
if (!sf) {return; }
fb = this.fullBounds();
rightOff = Math.min(
this.fullBounds().right() - sf.right(),
fb.right() - sf.right(),
sf.contents.right() - sf.right()
);
if (rightOff > 0) {
sf.contents.moveBy(new Point(-rightOff, 0));
}
leftOff = this.fullBounds().left() - sf.left();
leftOff = fb.left() - sf.left();
if (leftOff < 0) {
sf.contents.moveBy(new Point(-leftOff, 0));
}
topOff = this.fullBounds().top() - sf.top();
topOff = fb.top() - sf.top();
if (topOff < 0) {
sf.contents.moveBy(new Point(0, -topOff));
}
bottomOff = this.fullBounds().bottom() - sf.bottom();
bottomOff = fb.bottom() - sf.bottom();
if (bottomOff > 0) {
sf.contents.moveBy(new Point(0, -bottomOff));
}