Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6342695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:17:25+00:00 2026-05-24T20:17:25+00:00

var previousZone = null; //Evaluates whether the currently moused-over item is a RadDockZone. //TODO:

  • 0
var previousZone = null;
//Evaluates whether the currently moused-over item is a RadDockZone.
//TODO: Make more understandable.
function TryGetZoneFromTarget(target) {

    //Done for performance. Comparing object types is slower than a string comparison on ID.
    if (target != null && target.id && target.id.indexOf("RadDockZone") != -1) {
        return $find(target.id);
    }

    if (!target.id) {
        return "IGNORE";
    }

    return null;
}

//Adds highlighting to the dockZones when the user is dragging objects to the screen.
//Clear the old dockZone as the user moves out of it, and color new ones as they move into it.
function OnClientDragging(sender, eventArgs) {
    var target = eventArgs.get_htmlElement();
    var currentZone = TryGetZoneFromTarget(target);

    if (currentZone == "IGNORE") return; //When the user moves the mouse too fast inside of a zone, the zone returns no ID but this is a red-herring.
                                         //Ignoring this prevents flickering where we temporarily remove the highlighting on a zone when not moving out of it.

    if (currentZone) {
        dockZoneDroppedOnID = currentZone.get_id();

        if (previousZone == null) {
            previousZone = currentZone;
            AddHighlighting(currentZone);
        }
        else if (previousZone != currentZone) {
            RemoveHighlighting(previousZone);
            previousZone = currentZone;
            AddHighlighting(currentZone);
        }
    }
    else {
        dockZoneDroppedOnID = "";
        if (previousZone != null) {
            RemoveHighlighting(previousZone);
            previousZone = null;
        }
    }
}

So, I have a weird quirk which is making this method a lot uglier. When the client is dragging their mouse, if they drag too quickly, the target won’t return an ID when it actually has one. This was resulting in flickering, I would remove and re-add highlighting when not moving through a zone. As such, I patched in this quick fix… but it’s really bad.

What’s a proper way of handling such a scenario in Javascript? Should I have an enumeration of three types… “Zone”, “NotZone”, “Ignore” and work from there? Or…?

public class CormantRadListBox : RadListBox
{
    public CormantRadListBox()
    {
        EnableDragAndDrop = true;
        OnClientDragging = "OnClientDragging";
        OnClientDropping = "OnClientDropping";
        Sort = RadListBoxSort.Ascending;
        Skin = "Web20";
        Width = Unit.Percentage(100);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:17:27+00:00Added an answer on May 24, 2026 at 8:17 pm

    “A better way to write” is always subjective, but if what you mean is your drag zone is undefined, which is a different case than an empty/null result for drag zone, check for undefined, then null, then value:

    function TryGetZoneFromTarget(target) { 
    
         if(/\S/.test(e.target.id) == false){
               return undefined;
         }
    
         var c = $find(e.target.id);
    
         if(c && Telerik.Web.UI.RadDockZone.isInstanceOfType(c)) {
            return c;
         }
    
         return null;
    }
    
    function OnClientDragging(sender, eventArgs) {       
         var target = eventArgs.get_htmlElement();       
         var currentZone = TryGetZoneFromTarget(target);   
    
         if(currentZone === undefined) {
               // return or do nothing
         } else if(currentZone === null) {
               // do something 
         } else {
               // do something else
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

var y = new w(); var x = y.z; y.z= function() { doOneThing(); x();
var thumbs = document.getElementsByTagName(img); for (var i=0; i<thumbs.length; i++) { Core.addEventListener(thumbs[i], click, function() {alert(i);});
var CoreGroups = new function(){ this.name = function(){return 'name test'}; var functionName = function(){
var value; $(#Grid1).click(function(e) { var row = jQuery(e.target).parent(); value= row.attr(id); }); var onrowclick =
var results = ['one', 'two', 'one hundred', 'three']; var removal = []; $.each(results, function(i)
var plugin = { Init: function() { this.UpdateUI(); if (this.Status() == 1) { ...
var MyObj = function(h,w){ this.height = h; this.width = w; } I would like
var AppPatientsList = JSON.parse(JSON RESPONSE); var AppPatientsListSort = AppPatientsList.sort(function(a,b){ return a.firstName.toLowerCase() <b.firstName.toLowerCase() ? -1
var latlon = new LatLon(50,-0.075); setInterval(function(){ latlon = latlon.destinationPoint(randomBetween(0,360),0.001); },1000); Here is my very
var A = { method1 : function(){ // do some thing }, method2 :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.