import React, { Component } from "react";
import ReactDOM from "react-dom";
import { BrowserRouter } from 'react-router-dom';
import Main from "./component/main.component";
ReactDOM.render((
<BrowserRouter>
<Main />
</BrowserRouter>
), document.getElementById('root'));
import React, { Component } from "react";
import { BrowserRouter as Router, Switch, Route, Link, BrowserRouter } from 'react-router-dom';
import s from "./style.css";
import Header from "./header.component";
import Home from "./home.component";
import NewArrivals from "./newarrivals.component";
class Main extends Component {
render() {
return (
<div className={s.awesome}>
<Header />
<Router>
<Route exact path='/' component={Home}/>
<Route path='/new-arrivals/' component={NewArrivals}/>
</Router>
</div>
);
}
}
export default Main;
import React, { Component } from "react";
import { BrowserRouter as Router, Switch, Route, Link, BrowserRouter } from 'react-router-dom';
import s from "./style.css";
class Header extends Component {
render() {
return (
<header>
<Logotype/>
</header>
);
}
}
class Logotype extends Component {
onclick () {
document.querySelector('.'+s.home).classList.remove(s.hide);
document.querySelector('.'+s.line).classList.remove(s.hide);
}
render() {
return (
<h1 onClick={(e) => this.onclick(e)} className={s.logotype}>
<Link to='/new-arrivals/'>Awesome</Link>
<HeaderLine/>
</h1>
);
}
}
class HeaderLine extends Component {
render() {
return (
<span className={s.line}></span>
);
}
}
export default Header;
var GET = function() {
$('.form').removeClass('show');
data = form();
$.ajax({
url: 'functions.php',
dataType: 'html',
data: data,
type: 'GET'
})
.done(function(data) {
$('.form .section_body').html(data);
$('#submit span').html(action);
$('#submit').click(function(event) {
POST();
});
$('.form').addClass('show');
})
.fail(function() {
console.log("error");
});
}
var temp = 0;
$("section.items .sbody").scroll(function(event) {
var st = $("section.items .sbody .item").offset().top;
st = -(st - 160);
var row = Math.floor(st / 220) + 1;
var sh = row * 220;
if (row > temp) {
$("section.items .sbody").animate({ scrollTop: sh }, 500);
}
console.log(row);
temp = row;
});
Я понимаю, что можно привязать номер каждому элементу и через него подтягивать, но хотелось бы иначе.