- Create Account

DragResize - no resize

Forums > DragResize > DragResize - no resize
Author
Message

1) SamJJ Group: Guests
IP: 202.180.--.--
Hi,

How do I make one of the resizable DIVS non-resizable?
Don't want to change its size, dont want the handles.

I was hoping it was just a variable that passes through to the function like noresize. But can't figure it out.

Sam

2) Angus Turnbull Group: Moderators
Posts: 4235 Joined: 7 Dec 2003 Location: New Zealand IP: 125.238.--.--
Hmm! One way to do it would be to create a second dragresize object, call it dragresize2 for instance, and do this:

dragresize2.resizeHandleSet = null;
dragresize2.resizeHandleDrag = null;

That  will deactivate handle creation and dragging on that object. Hook that object up to use different classnames on elements and you're set.

Good luck - Angus.

3) SamJJ Group: Guests
IP: 202.180.--.--
Thanks very much for the reply.

That works perfect.

Sam

4) joe Group: Guests
IP: 151.203.--.--
I found a way to set Any obect non-resizeable and only dragable, by making a change to the code... I included a line in the function:

DragResize.prototype.resizeHandleSet = function(elm,  show) { with (this)
{
 // Either  creates, shows or hides the resize handles within an element.
if (!elm.noresize) { // added  line

and at the end of the function I added a }

Now,  anytime i want to disable re-sizing, i just add noresize=true to the element

5) Angus Turnbull Group: Moderators
Posts: 4235 Joined: 7 Dec 2003 Location: New Zealand IP: 203.173.--.--
Good idea. It would be slightly safer to test if elm.className contains "noresize" and put CLASS="whatever noresize" on the element, but the same kind of idea really!

- Angus.

6) Joe Group: Guests
IP: 151.203.--.--
I like the idea of putting noresize in the class attribute. The problem with that is i do a lot of className swapping. Having to filter out names just to swap a class is to much hastle, where just putting noresize as an attribute is so much simpler.

7) Alex Group: Guests
IP: 122.116.--.--
It's a useful function, but I find noresize effect only work in IE serials Browser, not work in Firefox Browser (I used FF 2.0.0.11)

Have Anyone get the same result?

[my script]----------------------------------

var divobj  = document.createElement('div');
divobj.className = 'drsElement';
divobj.setAttribute('class','drsElement');
divobj.setAttribute('noresize',true);
addEvent( divobj, "dblclick", function() {
    alert('new  function planning...');
    } );
divobj.id  = myid;
divobj.style.zindex = ID;

... some script to setup the divobj style ...

$('wb').appendChild(  divobj);
page.apply( $('wb'));

8) Angus Turnbull Group: Moderators
Posts: 4235 Joined: 7 Dec 2003 Location: New Zealand IP: 203.173.--.--
Like I was suggesting, browsers are theoretically free to disregard non-W3C properties like "noresize" on an element.

Seriously, if you're already using one of those '$' libraries like jQuery/Prototype, you should have a whole load of addClass or similar methods built in. Just use them and test className. It's not actually any more difficult!

- Angus.

9) Alex Group: Guests
IP: 122.116.--.--
Angus:

I only put

function $(v)  { return(document.getElementById(v)); }
function $S(v)  { return(document.getElementById(v).style); }

in  my script for DOM locating, do not use jQuery or Prototype...

by the way, In your opion, which library (jQuery, Prototype, Mootools) is best fit for you? I'll pick up one of them to cook my web application

Anyway, your idea and code affected someone programer like us, thks.

10) Angus Turnbull Group: Moderators
Posts: 4235 Joined: 7 Dec 2003 Location: New Zealand IP: 202.137.--.--
Oh, I don't use the major libraries a lot. I've used jQuery a little and it seems alright, plus Prototype has historically extended native objects (booo!). Really, any should work OK.

- Angus.

Post a Reply:

You are not logged in, and will be posting anonymously as a guest. If you want to post using an account, please login at the top of this page.