Results 1 to 3 of 3

Thread: Ext.Number.snap - can someone explain in details?

  1. #1
    Sencha User
    Join Date
    Apr 2013
    Location
    Bulgaria
    Posts
    6

    Default Answered: Ext.Number.snap - can someone explain in details?

    Hi all,

    I am new to extjs and am very curious how and why is this "Ext.Number.snap" used for? I read the documentation several times, but still it's not that clear to me.

    Thank you in advance and do please excuse me for the stupid question.

    Regards

  2. It's for implementing a 'snap to grid'. You can think of it as a sort of advanced rounding function.

    You could also think of it as a slider with discrete intervals.

    e.g. For percentages with intervals of 10% you might use:

    Code:
    Ext.Number.snap(3, 10, 0, 100); // => 0
    Ext.Number.snap(13, 10, 0, 100); // => 10
    Ext.Number.snap(17, 10, 0, 100); // => 20
    Ext.Number.snap(21, 10, 0, 100); // => 20
    This example is simply rounding to the nearest 10, constrained between 0 and 100.

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    It's for implementing a 'snap to grid'. You can think of it as a sort of advanced rounding function.

    You could also think of it as a slider with discrete intervals.

    e.g. For percentages with intervals of 10% you might use:

    Code:
    Ext.Number.snap(3, 10, 0, 100); // => 0
    Ext.Number.snap(13, 10, 0, 100); // => 10
    Ext.Number.snap(17, 10, 0, 100); // => 20
    Ext.Number.snap(21, 10, 0, 100); // => 20
    This example is simply rounding to the nearest 10, constrained between 0 and 100.

  4. #3
    Sencha User
    Join Date
    Apr 2013
    Location
    Bulgaria
    Posts
    6

    Default

    Thank you very much! Very well explained!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •