-
Notifications
You must be signed in to change notification settings - Fork 21
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
Can you please explain how to you the Affix Deirective please #72
Comments
Sorry I have been very busy lately finishing several projects for customer, so I haven't had the time to fully test this lib with latest versions of Angular2 and create proper examples for each part. That said, this is how I am currently using on one of my projects:
also, make sure you import |
Hi thanks for you quick response i implemented it i placed the ScrollSpyModule.forRoot() in the imports of my app.module.ts and i also placed the ScrollSpyAffixDirective in the app.module.ts in the declarations and import {ScrollSpyAffixDirective} from "ng2-scrollspy/src/plugin/affix.directive"; then i place [scrollSpyAffix]="{topMargin: 245, bottomMargin: 70}" on one of my divs in my app.component.html but i cannot get it to work. |
There has to be scrollSpy directive used in some parent element and then it will start to work. But it does not work same as bootstrap affix. This directive only set affixTop or affixBottom - single class affix missing. |
Sorry been busy but I am in the middle of finished this lib now. I hope to finish it during the weekend and include documentation for each component. |
@inzerceubytovani Also with next update I will include class affix that will be active if any off affixTop or affixBottom are active. Hope this solves your use case. |
I think it would be great if it worked like bootstrap affix : http://getbootstrap.com/javascript/#affix - there is also affix-top, affix-bottom and affix. |
Please try new version v0.3.0. Make sure you read docs for new declaration system. I will try to create more documentation and example during next week. |
@JonnyBGod thanks for your comment! I can't find the documentation you mentioned. I tried to use it this way:
I expected to have a class added / removed according to the scroll. Is it the expected behavior? Thanks very much for your help! |
Yes that should work. |
@JonnyBGod following your message, I investigated a bit more the problem. In fact, we need to specify a value as a number:
Thanks for the great tool! |
Can any one give compile example how to make it work ? and i get error: |
In fact, it's not related to ng2-scrollspy but to Angular2. You can only specify modules into the
|
yes ive done this but on first time I enter page it works but when i get back i get error: |
@felek000 That is just a warning message. Basically you are using |
Well fine but scroll is not working after. |
|
app.module template
I enter page 1 time ok, i refresh page ok. I go via click on different path in ap and get back same error. |
Ok it will work when i give scrollSpy on dont know if this is intended but it works. |
I have the same problem!
no effect |
@JonnyBGod looking back through this thread, the most troubling bit is this: "and declare ScrollSpyAffixDirective in the module you want to use it in" This will not work if you want to use this directive in more than one module of your application, which many of us will. A given directive can only be declared in one module. It seems like the module system is not set up correctly for scroll spy. There should be a module which I can import to every module where I want to use this directive and others, only that module should declare the directives. |
@kylecordes you can import |
@JonnyBGod Version 0.3.8, appears to be current on NPM, does not export a ScrollSpyAffixModule. |
It does from |
@JonnyBGod Thank you, I was able to import it from 'ng2-scrollspy/dist/plugin/affix' |
I have the following template
scrollSpy is working well, but scrollSpyAffix isn't. When scrolling, I always have
So my div is alway fixed. Why is it? |
With the help of @JonnyBGod I've created an example implementation https://ngx-scrollspy.now.sh The source can be found here https://github.com/beeman/ngx-scrollspy-angular-cli-demo |
Has anyone successfully gotten the affix directive working using the latest version of the package from npm - ngx-scrollspy, ver 1.2. |
@pthibodeaux July this year isn't that old. Try this. diff --git a/src/app/pages/pages.module.ts b/src/app/pages/pages.module.ts
index 400f26c..585e0bd 100644
--- a/src/app/pages/pages.module.ts
+++ b/src/app/pages/pages.module.ts
@@ -1,8 +1,8 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
-import { ScrollSpyIndexModule } from 'ngx-scrollspy/dist/plugin'
-import { ScrollSpyAffixModule } from 'ngx-scrollspy/dist/plugin/affix'
+import { ScrollSpyIndexModule } from 'ngx-scrollspy'
+import { ScrollSpyAffixModule } from 'ngx-scrollspy'
import { PagesRoutingModule } from './pages-routing.module';
|
Can you please explain how to you the Affix Deirective please
The text was updated successfully, but these errors were encountered: