Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Fabric.js getScrollLeftTop() Method

  • Last Updated : 25 May, 2021

The getScrollLeftTop() method in Fabric.js is used to find the scroll offsets of an element. The object returned by this method contains the “top” and “left” property that denotes the “top” and “left” offsets respectively. The HTML element in the page has to be selected first to pass this method.


Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!


Parameters: This method accepts a single parameter as mentioned above and described below:

  • element: This parameter is used to specify the HTML element for which the scroll offsets have to be found.

Return Value: This method returns an object that contains the “top” and “left” scroll offsets as properties.

The below example demonstrates the getScrollLeftTop() method Fabric.js:



    <!-- Adding the Fabric.js library -->
    <script src=
        /* Define the CSS classes to be used */
        .box1 {
            margin: 25px;
            width: 400px;
            height: 400px;
            background-color: red;
        .box2 {
            margin: 25px;
            width: 700px;
            height: 300px;
            background-color: green;
    <h1 style="color: green;">
        Fabric.js util.getScrollLeftTop() Method
    <div class="box1">
        Element 1
    <div class="box2">
        Element 2
        // Select the elements to be used
        let elem =
        let elem2 =
        function getScrollOffsets() {
                "Current Left and Top Offsets are:"
            // Find the scrolled left and top offsets
        // Repeatedly call the function
        // to observe the values
        setInterval(getScrollOffsets, 1000);


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!