css-func
Handle CSS style functions with no worries.
Install
npm i -S css-func
Usage
Examples on how it can be used
const cssfunc = ; // get dom elementconst element = document; // different ways to specify function parameters; // "translate(10px)"; // "translate(10px)"; // "translate(10px, 20px)" ; // "rotate(20deg)" console; // "translate(10px, 20px) rotate(20deg)"
Custom variable that holds the cssfunc
instance
const filters = ;filters;filters; filters;filters; filters; // false filters; // "grayscale(100%)"
API
get()
Gets the property from element
Examples
; // "translate(10px, 20px) scale(1.1)"
Returns
string
Element property value
add(fproperty, value[, autoUpdate=true])
Adds or updates a function
Parameters
Name | Type | Description | |
---|---|---|---|
fproperty | string |
CSS function name | |
value | string array |
CSS function parameters | |
autoUpdate=true | boolean |
True to automatically update function if aleady presentTrue to automatically add new function if not present | Optional |
Examples
;;;
Returns
boolean
True if a function was added or updated
update(fproperty, value[, autoAdd=true])
Updates or adds a function
Parameters
Name | Type | Description | |
---|---|---|---|
fproperty | string |
CSS function name | |
value | string array |
CSS function parameters | |
autoAdd=true | boolean |
True to automatically add new function if not present | Optional |
Examples
;
Returns
boolean
True if a function was updated or added
delete(fproperty)
Delete functoin from element style property
Parameters
Name | Type | Description | |
---|---|---|---|
fproperty | string |
CSS function name |
Examples
;
Returns
boolean
True if there was a function to delete
exists(fproperty)
Returns true if function exists
Parameters
Name | Type | Description | |
---|---|---|---|
fproperty | string |
CSS function name |
Examples
;
Returns
boolean
True if function exists