I'm aware of the ideologies of The Republican Party during reconstruction, which involved federal involvement in rebuilding states. I think the swapping of ideas between the parties happened sometime around the great depression when FDR supported rebuilding our economy through government intervention and creating mass amounts of jobs. But why did this change happen and was it over a long period of time or a short one?
Franklin Roosevelt’s rise to the presidency was largely built upon what historians have termed “The New Deal Coalition” a large and powerful voting block that for three decades dominated American electoral politics. The coalition consisted of white southerners, labor unions, blue collar workers, and ethnic minority groups. The demise of the coalition is credited to the white southerners joining the Republican Party, a critical swift that changed the fates of both parties. This is the "swap" of which you speak of in your question.
So why did these voters change parties? Ultimately it came down to southern whites becoming displeased with the Democratic Party for one large reason: civil rights. Up until the 1950s, both the Democratic and Republican Parties had liberal and conservative wings. By the 1960s, the liberal Democrats dominated Washington with figures like Lyndon Johnson, Hubert Humphrey, and Robert Kennedy who supported civil rights for African-Americans. Black America was making its voice heard and the liberal Democrats had listened, passing through landmark civil rights legislation under the Johnson Presidency. The significantly sized conservative wing of the party, which mostly consisted of segregationist whites who supported the New Deal policies Democrats continued to champion, were horrified that their party was calling for desegregation.
At the same time the conservative wing of the Republican Party was growing, especially as the result of conservative politics becoming more popular in the GOP-dominated Western United States. The influence of this movement was seen in the 1964 Republican primaries, where conservative Barry Goldwater handily beat out liberal Nelson Rockefeller. Most southern conservatives voted for Goldwater that year. While Goldwater lost in a landslide to Johnson, his ideology would live on, hence why many historians consider him the "father" of the modern GOP.
The Democrats split into two over the issue of African-Americans. The white southerners left to form their own party; the American Independence Party, also known as the Dixiecrats. Lead by George Wallace, they were openly segregationist and vowed to fight civil rights in all forms. In the 1968 elections, Wallace won 13.5% of the popular vote, one of the best ever for a third-party candidate. Former Goldwater voters in the south mostly switched to supporting Wallace.
The Republicans, sensing that they could win these voters dissatisfied by liberal Democrats, started a campaign plan known as the Southern Strategy to win southern states. The Southern Strategy wasn’t overtly segregationist, but it did play upon many racial fears southern whites had, particularly in regards to white opposition to affirmative action and desegregation busing. By criticizing these and other policies of the liberal Democrats, such as abortion rights, southerners who supported Goldwater and Wallace found a permanent home in the GOP. As a result, Republican candidates like Richard Nixon and Ronald Reagan won large landslides in the south.
Thus, by the 1980s all that remained of the Democrats were the liberals, the New Deal Coalition was dead. Meanwhile the liberal Republicans had died out as the result of Goldwater-style conservatism having taking over the party.