You will notice all examples import different parts of Quasar. However, if you need only one specific util method, then you can use ES6 destructuring to help Tree Shaking embed only that method and not all around it.
Example with dom utils:
import { dom } from'quasar' const { offset } = dom
This applies only when DomElement is visible! It returns the computed browser style, so the property you are asking for doesn’t necessary has to be applied within a style attribute.
import { dom } from'quasar' const { style } = dom
// Get COMPUTED style (when DomElement is visible!) // Computed means a DomElement might not have "height" CSS property set, // but that does not mean it doesn't have a height when it's displayed. // The following method accesses the computed CSS provided by the browser: console.log(style(DomElement, 'height')) // '10px' <<< notice it returns a String ending in 'px'
Get Height / Width
import { dom } from'quasar' const { height, width } = dom
// Some aliases of the previous method for "width" and "height" which // returns Numbers instead of Strings: console.log( height(DomElement), width(DomElement) ) // 10 100
Apply CSS Properties in Batch
import { dom } from'quasar' const { css } = dom
// Apply a list of CSS properties to a DomNode css(DomElement, { height: '10px', display: 'flex' })
Get Viewport Dimensions
import { dom } from'quasar' const { viewport } = dom
// Get Window height and width let {height, width} = viewport() console.log(height, width) // 800 600
Execute when DOM is ready
import { dom } from'quasar' const { ready } = dom
// Execute a Function when DOM is ready: ready(function () { // .... })
Get Crossbrowser CSS Transform Property
import { dom } from'quasar' const { cssTransform } = dom