BringIntoView on page load

6 posts, 0 answers
  1. George
    George avatar
    7 posts
    Member since:
    Dec 2013

    Posted 22 Jun 2015 Link to this post

    Hello,

    I'm calling bringIntoView() once my diagram has been initialized, in order to fit the diagram into the space available.

    I'm doing that by subscribing to the requestEnd event of the datasource, as below:

    var datasource = new kendo.data.DataSource({
        transport: {
            read: {
                url: "MyDataUrl",
                type: "POST",
                dataType: "json",
            }
        },
        requestEnd: function(e) {
            setTimeout(function() { ZoomToFit(); },200);
        },
    });
     
    function ZoomToFit() {
        var diagram = $("#myDiagram").getKendoDiagram();
        diagram.bringIntoView(diagram.shapes);
    }

    I found that calling ZoomToFit() directly from the event was too quick, and would attempt to perform the action before the diagram had been initially displayed, so I used a timeout.

    The problem I have is that in some cases, even with the timeout, the ZoomToFit() method is called before the diagram is initially displayed.

    I therefore need a method of performing that initial bringIntoView() as soon as the diagram has been displayed. Is there a better event I should be using?

    Note that calling bringIntoView() straight after initializing the diagram is also too early, it would seem. And I can't just extend the timeout, as this will be perceived as a jump, for users whose diagram does display quickly.

    Thanks,

    George

  2. T. Tsonev
    Admin
    T. Tsonev avatar
    2770 posts

    Posted 25 Jun 2015 Link to this post

    Hi,

    Please accept my apologies for the delayed response.

    The most appropriate moment for calling bringIntoView is in the dataBound handler. Note that it still needs a timeout:
            function onDataBound(e) {
                var that = this;
                setTimeout(function () {
                    that.bringIntoView(that.shapes);
                }, 0);
            }

     

    This is something that we need to look into. Maybe a special event handler is in order.
    Apologies for the caused inconvenience.

    Regards,
    T. Tsonev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. George
    George avatar
    7 posts
    Member since:
    Dec 2013

    Posted 25 Jun 2015 in reply to T. Tsonev Link to this post

    OK, thanks for the info.

    I'll use onDataBound, as you suggest, but it would really be of value if you could implement a new event handler in a future release.

    Many thanks,

    George

  5. T. Tsonev
    Admin
    T. Tsonev avatar
    2770 posts

    Posted 29 Jun 2015 Link to this post

    Hi,

    We might move the dataBound event to trigger a bit later when the shapes are created.
    This doesn't sound like it will break something, but it will remove the need for a separate event.

    Regards,
    T. Tsonev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. George
    George avatar
    7 posts
    Member since:
    Dec 2013

    Posted 06 Jul 2015 in reply to T. Tsonev Link to this post

    Thanks for the update.

    I've now implemented it using the dataBound event, as you suggested.

    Presumably this will not require a change on our part once you've modified the timing of that event. It should just seamlessly work.

    Thanks,

    George

  7. T. Tsonev
    Admin
    T. Tsonev avatar
    2770 posts

    Posted 06 Jul 2015 Link to this post

    Hello,

    Indeed, this is our plan as well. We try not to break client code whenever possible.

    Regards,
    T. Tsonev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready