Based on the coordinates set the absolute position of the control (overlay) to display it accordingly. The overlay can be started any side/corner of the element.
Get the element object using JQuery:
var obj = $('[id$=controlelement]');Get the position of the element from Left
function findPosLeft(obj)Get the position of the element from Top
{
var pos = obj.offset();
var left = pos.left;
return left;
}
function findPosTop(obj)Get the position of the element from Bottom
{
var pos = obj.offset();
var top = pos.top;
return top;
}
function findPosBottom(obj)Get the position of the element from Right
{
var pos = obj.offset();
var top = pos.top;
var height = obj.height();
var bottom = top + height;
return bottom;
}
function findPosRight(obj)
{
var pos = obj.offset();
var left = pos.left;
var width = obj.width();
var right = left + width;
return right;
}
Better i would use for finding top position is
ReplyDelete"return obj.offset().top;"
And also i dont think it should be a method we can directly use object.offset().top;
Kranthi,
ReplyDeleteWell, it can be used directly as you said. However functions are always Reusable & Scalable and also a best practice for operations.
Well written post.It help to create an axis.It help my professional many times.Please create more blogs related.Thanks for it.
ReplyDeleteEcommerce developer