Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home for dartlang.org
« Groups Home
Width of an element
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
santiagorios  
View profile  
 More options Aug 20 2012, 5:30 pm
From: santiagorios <santi...@woven.org>
Date: Mon, 20 Aug 2012 14:30:30 -0700 (PDT)
Local: Mon, Aug 20 2012 5:30 pm
Subject: Width of an element

Hello everyone in the dart community,

I've just started working with Dart, I'm exploring and trying to learn how
it works and so far it's been a great journey. However, I just run into a
problem which I haven't been able to figure out yet. I'm probably missing
something very simple.

I have the following html:

<div id="test"><a href="photos/photo12.jpg"><img
src="photos/photo12.jpg"></a></div>

What I'm trying to do is get the width of both, the div and the img. So far
I have been able to get the width for the image but I can't find a way to
get the width of the div. This is the code that I have in place:

int imgWidth = query('#test').query('img').width;

int divWidth = query('#test').width;

The first line works like a charm, but the second one is raising an error.
I have been researching and I have found some sources saying that using the
dart:dom library is the way to go, but since that library has been
deprecated, I'm trying to find a way to accomplish this by just using
the dart:html library.

Thank you so much for any help or guidance, it's very appreciated. :)

Santiago


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Seth Ladd  
View profile   Translate to Translated (View Original)
 More options Aug 20 2012, 5:42 pm
From: Seth Ladd <sethl...@google.com>
Date: Mon, 20 Aug 2012 14:42:34 -0700
Local: Mon, Aug 20 2012 5:42 pm
Subject: Re: [dart-misc] Width of an element

Hi Santiago,

Thanks for the question! You might be interested
Element.rect()<http://api.dartlang.org/docs/continuous/dart_html/Element.html#rect>.
From the ElementRect you can get to the ClientRect, which has a width.

BTW, in the future, Stack
Overflow<http://stackoverflow.com/questions/tagged/dart>is a great
place to ask these kinds of questions.

Hope that helps, keep us posted!
Seth


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
santiagorios  
View profile  
 More options Aug 21 2012, 11:29 am
From: santiagorios <santi...@woven.org>
Date: Tue, 21 Aug 2012 08:29:35 -0700 (PDT)
Local: Tues, Aug 21 2012 11:29 am
Subject: Re: [dart-misc] Width of an element

Hello Seth,

Thank you so much for your answer. After I followed your suggestion I was
able to accomplish the task that was before me.

Just as a future reference if someone is trying to accomplish a similar
task, the code that did the trick for me was:

query("#test").rect.then((ElementRect r) {
  int imgWidth = query('#test').query('img').width;
  int divWidth = r.client.width;

});

I'll make sure to make my future questions in Stack Overflow. :)

Thank you,

Santiago


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Seth Ladd  
View profile   Translate to Translated (View Original)
 More options Aug 21 2012, 12:40 pm
From: Seth Ladd <sethl...@google.com>
Date: Tue, 21 Aug 2012 09:40:48 -0700
Local: Tues, Aug 21 2012 12:40 pm
Subject: Re: [dart-misc] Width of an element

Glad it worked! And thanks for posting your solution, that will help future
Dart users. :)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »