Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #30396 > unrolled thread

Will insertBefore show it IMMEDIATELY?

Started bybit-naughty@hotmail.com
First post2016-05-04 23:06 -0700
Last post2016-05-11 17:34 +0300
Articles 12 — 8 participants

Back to article view | Back to comp.lang.javascript


Contents

  Will insertBefore show it IMMEDIATELY? bit-naughty@hotmail.com - 2016-05-04 23:06 -0700
    Re: Will insertBefore show it IMMEDIATELY? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-05-05 10:16 +0100
      Re: Will insertBefore show it IMMEDIATELY? Steve L <x@y.z> - 2016-05-07 15:40 -0400
        Re: Will insertBefore show it IMMEDIATELY? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-05-07 22:51 +0200
          Re: Will insertBefore show it IMMEDIATELY? Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-05-08 19:18 +0100
    Re: Will insertBefore show it IMMEDIATELY? "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-05-06 12:53 +0200
      Re: Will insertBefore show it IMMEDIATELY? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-05-06 13:11 +0200
      Re: Will insertBefore show it IMMEDIATELY? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-05-06 14:08 +0200
        Re: Will insertBefore show it IMMEDIATELY? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-05-06 16:10 +0200
    Re: Will insertBefore show it IMMEDIATELY? bit-naughty@hotmail.com - 2016-05-10 00:53 -0700
      Re: Will insertBefore show it IMMEDIATELY? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-05-10 10:38 +0200
      Re: Will insertBefore show it IMMEDIATELY? Osmo Saarikumpu <osmo@weppipakki.com> - 2016-05-11 17:34 +0300

#30396 — Will insertBefore show it IMMEDIATELY?

Frombit-naughty@hotmail.com
Date2016-05-04 23:06 -0700
SubjectWill insertBefore show it IMMEDIATELY?
Message-ID<9f3351d4-6b6a-46f3-b086-41f39990ab7b@googlegroups.com>
Hi,
I posted before about this in my ealier AppendSibling post, but I think no one heard me!

My question is, if I use this, as instructed:
insertBefore(newChild, 
refChild) method. 

Then will the element show up right away?
I DON'T want it to, I want it to remain invisible till I fiddle with it's CSS properties....


Thanks.

[toc] | [next] | [standalone]


#30397

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-05-05 10:16 +0100
Message-ID<87d1p0vp85.fsf@bsb.me.uk>
In reply to#30396
bit-naughty@hotmail.com writes:
<snip>
> My question is, if I use this, as instructed:
> insertBefore(newChild, 
> refChild) method. 
>
> Then will the element show up right away?
> I DON'T want it to, I want it to remain invisible till I fiddle with
> it's CSS properties....

Make sure that the initial properties render it invisible.  Make it
visible (by whatever means you are using -- the position, visibility or
display properties) only when it is ready to be seen.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#30409

FromSteve L <x@y.z>
Date2016-05-07 15:40 -0400
Message-ID<logsibheqccl6jtmlrbknqdq8ghud4qips@4ax.com>
In reply to#30397
On Thu, 05 May 2016 10:16:58 +0100, Ben Bacarisse
<ben.usenet@bsb.me.uk> wrote:

>bit-naughty@hotmail.com writes:
><snip>
>> My question is, if I use this, as instructed:
>> insertBefore(newChild, 
>> refChild) method. 
>>
>> Then will the element show up right away?
>> I DON'T want it to, I want it to remain invisible till I fiddle with
>> it's CSS properties....
>
>Make sure that the initial properties render it invisible.  Make it
>visible (by whatever means you are using -- the position, visibility or
>display properties) only when it is ready to be seen.

My experience is from several years ago so maybe things have changed.
IIRC updates to the document are not rendered until the current script
has finished or has suspended execution. In situations where I DID
want the document to update immediately I had to use a short
setTimeout to pause execution.

[toc] | [prev] | [next] | [standalone]


#30410

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2016-05-07 22:51 +0200
Message-ID<2597183.QcWBBMbo8E@PointedEars.de>
In reply to#30409
Steve L <x@y.z> wrote:
        ^^^^^^^
Your “From” is in violation of network standards, Netiquette, and
maybe even the Acceptable Use Policy of your service provider.
You have been warned.

> On Thu, 05 May 2016 10:16:58 +0100, Ben Bacarisse
> <ben.usenet@bsb.me.uk> wrote:

Attribution line, not attribution novel.

>>bit-naughty@hotmail.com writes:
>>Make sure that the initial properties render it invisible.  Make it
>>visible (by whatever means you are using -- the position, visibility or
>>display properties) only when it is ready to be seen.
> 
> My experience is from several years ago so maybe things have changed.
> IIRC updates to the document are not rendered until the current script
> has finished 

Unreliable.  The only reliable way to avoid additional repaint is to not 
insert the element object into the document tree before its CSS properties 
have been set.

> or has suspended execution.

Impossible.

> In situations where I DID want the document to update immediately I had to
> use a short setTimeout to pause execution.

Still true, except that window.setTimeout() has never paused execution (that 
is a common misconception).  Instead, code that is to run independent of 
window updates and would potentially block execution, is to be executed with 
window.setTimeout() or the Web Workers API.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#30412

FromDr J R Stockton <reply1600@merlyn.demon.co.uk.invalid>
Date2016-05-08 19:18 +0100
Message-ID<pIuTXQG6L4LXFwa1@invalid.uk.co.demon.merlyn.invalid>
In reply to#30410
In comp.lang.javascript message <2597183.QcWBBMbo8E@PointedEars.de>,
Sat, 7 May 2016 22:51:48, Thomas 'PointedEars' Lahn <PointedEars@web.de>
posted:

>> In situations where I DID want the document to update immediately I had to
>> use a short setTimeout to pause execution.
>
>Still true, except that window.setTimeout() has never paused execution (that
>is a common misconception).  Instead, code that is to run independent of
>window updates and would potentially block execution, is to be executed with
>window.setTimeout() or the Web Workers API.

You are, as is customary, unnecessarily pedantic whenever that enables
you to avoid being helpful.


The setTimeout call does not of itself pause execution; but it can be
used to enable execution to restart after it stops for other reasons.
it and setInterval thereby provide /sine qua non/s for the pausing of
execution.

Pseudo-Pascal, as I am not set up to test it now :
        function F() ; begin
          Write(1) ;
          Pause(1000) ;
          Write(2)
          end ;

Pseudo-JavaScript :
        function F() {
          Write(1)
          setTimeout(G, 1000)
          }

        function G() :
          Write(2)
          ;

RBTD.

-- 
 (c) John Stockton, Surrey, UK.  ¬@merlyn.demon.co.uk   Turnpike v6.05   MIME.
 Merlyn Web Site <                       > - FAQish topics, acronyms, & links.

[toc] | [prev] | [next] | [standalone]


#30400

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2016-05-06 12:53 +0200
Message-ID<nght24$lte$1@solani.org>
In reply to#30396
bit-naughty@hotmail.com wrote:

> My question is, if I use this, as instructed:
> insertBefore(newChild, 
> refChild) method. 
> 
> Then will the element show up right away?
> I DON'T want it to, I want it to remain invisible till I fiddle with it's CSS properties....

Consider to use CSS for styling instead of doing this by scripting.  The
script would only add (or remove) a class name, then.

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#30402

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-05-06 13:11 +0200
Message-ID<XnsA6008638C31E4eejj99@194.109.6.166>
In reply to#30400
"Christoph M. Becker" wrote on 06 May 2016 in comp.lang.javascript: 
> bit-naughty@hotmail.com wrote:
> 
>> My question is, if I use this, as instructed:
>> insertBefore(newChild, 
>> refChild) method. 
>> 
>> Then will the element show up right away?
>> I DON'T want it to, I want it to remain invisible till I fiddle with
>> it's CSS properties.... 
> 
> Consider to use CSS for styling instead of doing this by scripting.  The
> script would only add (or remove) a class name, then.

On the other hand, 
why wouldn't you [if you must] 'fiddle with it's CSS properties' 
BEFORE you do the insertBefore()?

The Q sounds like "how to start masturbating after ejaculation?"
Or is that a bit too naughty for you?

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#30404

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2016-05-06 14:08 +0200
Message-ID<2621985.gYTYDU9glv@PointedEars.de>
In reply to#30400
Christoph M. Becker wrote:

> bit-naughty@hotmail.com wrote:
>> My question is, if I use this, as instructed:
>> insertBefore(newChild,
>> refChild) method.
>> 
>> Then will the element show up right away?
>> I DON'T want it to, I want it to remain invisible till I fiddle with it's
>> CSS properties....
> 
> Consider to use CSS for styling instead of doing this by scripting.  The
> script would only add (or remove) a class name, then.

False dilemma.

If newChild.style.display == "none" or 
document.defaultView.getComputedStyle(newChild, 
null).getPropertyValue("display") == "none", then even the dynamically 
inserted element will not be displayed immediately, and it may be necessary, 
depending on the use-case, to not have the element in the document tree from 
the beginning.

However, you are correct that once the element is in the document tree, 
toggling its “display” property (or other CSS properties) should be done 
with class name toggling, unless there is a good reason not to.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#30406

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-05-06 16:10 +0200
Message-ID<XnsA600A49B0C49Beejj99@194.109.6.166>
In reply to#30404
Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote on 06 May 2016 in
comp.lang.javascript: 

> However, you are correct that once the element is in the document tree, 
> toggling its ƒ odisplayƒ   property (or other CSS properties) should be
> done with class name toggling, unless there is a good reason not to.

Nonsense. That is just your personal dogma.

It can be done in many ways, unless there is a good reason not to.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#30416

Frombit-naughty@hotmail.com
Date2016-05-10 00:53 -0700
Message-ID<13b8c769-25d8-45b1-b0ff-9f7cdd1f994f@googlegroups.com>
In reply to#30396
Sorry, I have a question:

I want to insert AFTER the only child there is, ie. say there's a LIST "Water", and I want to insert "Fire" AFTER the "Water" -then what do I do?


Thanks.

[toc] | [prev] | [next] | [standalone]


#30418

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-05-10 10:38 +0200
Message-ID<XnsA6046C2F64BDCeejj99@194.109.6.166>
In reply to#30416
bit-naughty@hotmail.com wrote on 10 May 2016 in comp.lang.javascript:

> Sorry, I have a question:

Indeed, you should be.

If you have a new Q start a new thread.

If you are responding to something, quote that something.

> I want to insert AFTER the only child there is, ie. say there's a LIST
> "Water", and I want to insert "Fire" AFTER the "Water" -then what do I
> do? 

That is simple, you research on the web before asking us to do your work.


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#30424

FromOsmo Saarikumpu <osmo@weppipakki.com>
Date2016-05-11 17:34 +0300
Message-ID<ngvfmq$hda$1@dont-email.me>
In reply to#30416
On 10/05/2016 10:53, bit-naughty@hotmail.com wrote:
> I want to insert AFTER the only child there is, ie. say there's a LIST "Water", and I want to insert "Fire" AFTER the "Water" -then what do I do?

Replace 'insert' with 'append', but lmgtfy:

http://fi.lmgtfy.com/?q=appendChild

-- 
Best wishes, Osmo

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web