Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/cssjanus.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,17 @@ function CSSJanus() {
* @return {string} Inverted property
*/
function calculateNewBackgroundPosition( match, pre, value ) {
var idx, len;
// Check if inside a known color function
var lowerPre = pre.toLowerCase();
if (/(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix|linear-gradient)\(/.test(lowerPre)) {
// Do not flip if inside a color function
return pre + value;
}

if ( value.slice( -1 ) === '%' ) {
idx = value.indexOf( '.' );
var idx = value.indexOf( '.' );
if ( idx !== -1 ) {
// Two off, one for the "%" at the end, one for the dot itself
len = value.length - idx - 2;
var len = value.length - idx - 2;
value = 100 - parseFloat( value );
value = value.toFixed( len ) + '%';
} else {
Expand Down