Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add component to specific index #2540

Closed
wants to merge 18 commits into from
Closed

add component to specific index #2540

wants to merge 18 commits into from

Conversation

erikyuzwa
Copy link
Contributor

and tests

@heff my humble apologies for a PR this way. I did attempt to use contrib feature submit as per docs, but I was getting an ----->undefined as a response after answering all the prompts.

this corresponds with issue #2534

@pam
Copy link

pam commented Sep 2, 2015

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: 80d8f26
Build details: https://travis-ci.org/pam/video.js/builds/78336230

(Please note that this is a fully automated comment.)

@heff
Copy link
Member

heff commented Sep 2, 2015

A suggestion PR made here: https://github.com/erikyuzwa/video.js/pull/1

@pam
Copy link

pam commented Sep 2, 2015

Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED

Commit: 19cad93
Build details: https://travis-ci.org/pam/video.js/builds/78467615

(Please note that this is a fully automated comment.)

@pam
Copy link

pam commented Sep 2, 2015

Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED

Commit: 0527665
Build details: https://travis-ci.org/pam/video.js/builds/78469829

(Please note that this is a fully automated comment.)

@erikyuzwa erikyuzwa closed this Sep 3, 2015
@heff
Copy link
Member

heff commented Sep 3, 2015

We can keep this open until we can fix the last broken test. Not sure if you meant to close it.

@erikyuzwa erikyuzwa reopened this Sep 3, 2015
@erikyuzwa
Copy link
Contributor Author

sounds good -- wasn't sure if you were getting annoying travis alerts or something because of the failed tests. ;)

@erikyuzwa
Copy link
Contributor Author

after going through the sandbox dev server, I was able to make the failing test pass with:

ok(player.el().children[player.el().children.length-1].className.indexOf('vjs-tech') !== -1, 'media controller loaded');

the vjs-tech element was pushed to the tail of the Array rather than the head.

screen shot 2015-09-02 at 11 21 52 pm

@pam
Copy link

pam commented Sep 3, 2015

Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED

Commit: d763d0e
Build details: https://travis-ci.org/pam/video.js/builds/78520405

(Please note that this is a fully automated comment.)

@heff
Copy link
Member

heff commented Sep 3, 2015

Yeah, the problem is we need the tech to be first, always, so that other components in the player overlap the video.

The problem is we're adding the tech directly to the player element instead of using the addChild function of the player. This means it doesn't get added to the children array or any of the child indexes. So now when we try to insert other elements into the right place using the index of the children array, it doesn't match up with the indexes of where the child elements actually are in the player element... I think the solution is to make loadTech use the addChild function, but it's a little more complicated than just switching it.

@erikyuzwa
Copy link
Contributor Author

leave it to me to find the trickiest thing to tweak. I'm hoping the end result is an approach that really benefits users. I'll take a look at the player then and use your advice as a roadmap, many thanks.

@heff
Copy link
Member

heff commented Sep 3, 2015 via email

@erikyuzwa
Copy link
Contributor Author

aye

using the updated addChild to add our vjs-tech into our DOM children array
@erikyuzwa
Copy link
Contributor Author

made use of the addChild method as per your recommendation. The vjs-tech element is now appearing first in the children array. (was that empty div always there?)

screen shot 2015-09-03 at 9 10 31 pm

@pam
Copy link

pam commented Sep 4, 2015

Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED

Commit: 0f02202
Build details: https://travis-ci.org/pam/video.js/builds/78692641

(Please note that this is a fully automated comment.)

@erikyuzwa
Copy link
Contributor Author

hey @heff, I know it's a crazy month - just wondering if you've had a chance to look at my latest commit to see if this is in the right direction.

@nickygerritsen
Copy link
Contributor

This PR makes me happy 😃.

Anyway, aren't the tests missing stuff that tests the el() is in the correct position?

@erikyuzwa
Copy link
Contributor Author

thanks @nickygerritsen 👍 - yes great point, I shall work at that to try and see this PR through

@nickygerritsen
Copy link
Contributor

@erikyuzwa any update on this :)?

@nickygerritsen
Copy link
Contributor

Btw, would you also consider adding addChildBefore and addChildAfter? I think this makes sense with this index-based child adding and shouldn't be too hard?

Something like:

addChildBefore(child, before, options={}) {
  this.addChild(child, options, getChildIndex(before));
}

addChildAfter(child, after, options={}) {
  this.addChild(child, options, getChildIndex(after) + 1);
}

getChildIndex(child) {
  let component;
  if (typeof child === 'string') {
    component = this.getChild(child);
  } else {
    component = child;
  }

  let index = this.children_.indexOf(component);

  if (index === -1) { /* Throw some error? */ }

  return index;
}

Or similar.

I think it would make sense for something like this? Normally you want to insert a child at a given index because you want it to appear before / after some other component (actually exactly as you suggested in #2534).

@erikyuzwa
Copy link
Contributor Author

hey @nickygerritsen - hmm perhaps to try and keep this PR as "small" as possible (and in motion), I'd suggest creating a PR of your own once / if this one goes through. Ultimately it'd be up to @heff and the videojs team.

@gkatsev gkatsev added enhancement minor This PR can be added to a minor release. It should not be added to a patch release. needs: LGTM Needs one or more additional approvals labels Jan 16, 2016
@erikyuzwa
Copy link
Contributor Author

Thanks @gkatsev - much appreciated. I'll take a look for that module. Once I find it, I might submit a PR on the readme to update that submission section to help others out.

@gkatsev
Copy link
Member

gkatsev commented Jan 17, 2016

Yeah, the contributing.md is kind of outdated right now. It's on my TODO to update it.

@erikyuzwa
Copy link
Contributor Author

I get it. You're swamped, no worries.
If this is the correct contrib - https://www.npmjs.com/package/contrib - then I can submit a document PR myself.

@@ -405,7 +406,9 @@ class Component {
// Add the UI object's element to the container div (box)
// Having an element is not required
if (typeof component.el === 'function' && component.el()) {
this.contentEl().appendChild(component.el());
var childNodes = this.contentEl().children;
var refNode = childNodes[index] || undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't refNode end up pointing at the current element? oh, I see now that it would be pointing at the current position in the elements list so it would be exactly the item we want to use here.

Also, it would automatically get the value undefined if childNodes[index] doesn't exist. It would be better to use || null.

@gkatsev
Copy link
Member

gkatsev commented Feb 2, 2016

@erikyuzwa hey, finally got around to reviewing it. Made a few comments. Thanks.

@erikyuzwa
Copy link
Contributor Author

oh awesome - my humble thanks @gkatsev - always looking to improving my output. I'll take a look at your comments.

@gkatsev gkatsev added in progress and removed needs: LGTM Needs one or more additional approvals labels Feb 3, 2016
@gkatsev
Copy link
Member

gkatsev commented Feb 4, 2016

Thanks. LGTM.

@gkatsev gkatsev added the needs: LGTM Needs one or more additional approvals label Feb 4, 2016
@dmlap
Copy link
Member

dmlap commented Feb 4, 2016

LGTM

@gkatsev gkatsev removed the needs: LGTM Needs one or more additional approvals label Feb 4, 2016
@gkatsev gkatsev closed this in fc7a166 Feb 4, 2016
@gkatsev
Copy link
Member

gkatsev commented Feb 4, 2016

@erikyuzwa Thanks!

@gkatsev
Copy link
Member

gkatsev commented Feb 4, 2016

And it's out in 5.7.0! (Not yet on the CDN, but available in github releases and npm as next tag).

@erikyuzwa
Copy link
Contributor Author

most excellent - thanks @gkatsev and @dmlap for all the help!

SunnyLi added a commit to SunnyLi/videojs-ass that referenced this pull request Aug 6, 2016
properly add overlay as a player component so that video.js will
be aware of its existence when initializing additional components;
not inserting those before the overlay unless specified otherwise.
See videojs/video.js#2540

Fixes #11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement in progress minor This PR can be added to a minor release. It should not be added to a patch release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants