auto-animate; don't scale between text blocks

This commit is contained in:
Hakim El Hattab 2020-02-06 14:53:45 +01:00
parent e5ba80478d
commit c64206180d

View File

@ -204,12 +204,12 @@
autoAnimateStyles: [ autoAnimateStyles: [
{ property: 'opacity' }, { property: 'opacity' },
{ property: 'color' }, { property: 'color' },
{ property: 'backgroundColor' }, { property: 'background-color' },
{ property: 'padding', defaultValue: 'computed' }, { property: 'padding' },
{ property: 'font-size', defaultValue: 'computed' }, { property: 'font-size' },
{ property: 'line-height', defaultValue: 'computed' }, { property: 'line-height' },
{ property: 'letter-spacing', defaultValue: 'computed' }, { property: 'letter-spacing' },
{ property: 'border-width', defaultValue: 'computed' }, { property: 'border-width' },
{ property: 'border-color' }, { property: 'border-color' },
{ property: 'border-top-left-radius' }, { property: 'border-top-left-radius' },
{ property: 'border-top-right-radius' }, { property: 'border-top-right-radius' },
@ -3979,7 +3979,7 @@
else { else {
value = element.style[style.property]; value = element.style[style.property];
if( value === '' && style.defaultValue === 'computed' ) { if( value === '' ) {
computedStyles = computedStyles || window.getComputedStyle( element ); computedStyles = computedStyles || window.getComputedStyle( element );
value = computedStyles[style.property]; value = computedStyles[style.property];
} }
@ -4048,18 +4048,21 @@
}; };
var textNodes = 'h1, h2, h3, h4, h5, h6, p, li, span';
var mediaNodes = 'img, video, iframe';
// Eplicit matches via data-id // Eplicit matches via data-id
findMatches( '[data-id]', function( node ) { findMatches( '[data-id]', function( node ) {
return node.nodeName + ':::' + node.getAttribute( 'data-id' ); return node.nodeName + ':::' + node.getAttribute( 'data-id' );
} ); } );
// Text // Text
findMatches( 'h1, h2, h3, h4, h5, h6, p, li, span', function( node ) { findMatches( textNodes, function( node ) {
return node.nodeName + ':::' + node.innerText; return node.nodeName + ':::' + node.innerText;
} ); }, null );
// Media // Media
findMatches( 'img, video, iframe', function( node ) { findMatches( mediaNodes, function( node ) {
return node.nodeName + ':::' + ( node.getAttribute( 'src' ) || node.getAttribute( 'data-src' ) ); return node.nodeName + ':::' + ( node.getAttribute( 'src' ) || node.getAttribute( 'data-src' ) );
} ); } );
@ -4070,6 +4073,19 @@
return element.parentNode; return element.parentNode;
} ); } );
pairs.forEach( function( pair ) {
var fromElement = pair[0];
var matchesMethod = fromElement.matches || fromElement.matchesSelector || fromElement.msMatchesSelector;
// Disable scale transformations on text nodes, we transiition
// each individual text property instead
if( matchesMethod.call( fromElement, textNodes ) ) {
pair[2] = { scale: false };
}
} );
return pairs; return pairs;
} }